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.



328
329
330
331
# File 'lib/prismic/fragments/structured_text.rb', line 328

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

Instance Attribute Details

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#viewObject

Returns the value of attribute view.



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

def view
  @view
end

Instance Method Details

#altObject



345
346
347
# File 'lib/prismic/fragments/structured_text.rb', line 345

def alt
  @view.alt
end

#as_html(link_resolver, html_serializer = nil) ⇒ Object



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

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


349
350
351
# File 'lib/prismic/fragments/structured_text.rb', line 349

def copyright
  @view.copyright
end

#heightObject



341
342
343
# File 'lib/prismic/fragments/structured_text.rb', line 341

def height
  @view.height
end


353
354
355
# File 'lib/prismic/fragments/structured_text.rb', line 353

def link_to
  @view.link_to
end

#urlObject



333
334
335
# File 'lib/prismic/fragments/structured_text.rb', line 333

def url
  @view.url
end

#widthObject



337
338
339
# File 'lib/prismic/fragments/structured_text.rb', line 337

def width
  @view.width
end