Class: Prismic::Fragments::StructuredText::Block::Image

Inherits:
Prismic::Fragments::StructuredText::Block show all
Defined in:
lib/prismic/fragments/structured_text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Prismic::Fragments::StructuredText::Block

#as_text

Constructor Details

#initialize(view, label = nil) ⇒ Image

Returns a new instance of Image



326
327
328
329
# File 'lib/prismic/fragments/structured_text.rb', line 326

def initialize(view, label = nil)
  @view = view
  @label = label
end

Instance Attribute Details

#labelObject

Returns the value of attribute label



324
325
326
# File 'lib/prismic/fragments/structured_text.rb', line 324

def label
  @label
end

#viewObject

Returns the value of attribute view



324
325
326
# File 'lib/prismic/fragments/structured_text.rb', line 324

def view
  @view
end

Instance Method Details

#altObject



343
344
345
# File 'lib/prismic/fragments/structured_text.rb', line 343

def alt
  @view.alt
end

#as_html(link_resolver, html_serializer = nil) ⇒ Object



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/prismic/fragments/structured_text.rb', line 355

def as_html(link_resolver, html_serializer = nil)
  custom = nil
  unless html_serializer.nil?
    custom = html_serializer.serialize(self, '')
  end
  if custom.nil?
    classes = ['block-img']
    unless @label.nil?
      classes.push(@label)
    end
    %(<p class="#{classes.join(' ')}">#{view.as_html(link_resolver)}</p>)
  else
    custom
  end
end


347
348
349
# File 'lib/prismic/fragments/structured_text.rb', line 347

def copyright
  @view.copyright
end

#heightObject



339
340
341
# File 'lib/prismic/fragments/structured_text.rb', line 339

def height
  @view.height
end


351
352
353
# File 'lib/prismic/fragments/structured_text.rb', line 351

def link_to
  @view.link_to
end

#urlObject



331
332
333
# File 'lib/prismic/fragments/structured_text.rb', line 331

def url
  @view.url
end

#widthObject



335
336
337
# File 'lib/prismic/fragments/structured_text.rb', line 335

def width
  @view.width
end