Class: ClayText::Paragraph

Inherits:
Object
  • Object
show all
Defined in:
lib/clayoven/claytext.rb

Overview

A paragraph of text

:content contains its content :fist asserts whether it’s the first paragraph in the body :type can be one of PARAGRAPH_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Paragraph

Returns a new instance of Paragraph.



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/clayoven/claytext.rb', line 49

def initialize(content)
  @content = content
  @first = false
  @type = :plain

  # Generate is_*? methods for PARAGRAPH_TYPES
  Paragraph.class_eval do
    ClayText::PARAGRAPH_TYPES.each do |type|
      define_method("is_#{type.to_s}?") { @type == type }
    end
  end
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



47
48
49
# File 'lib/clayoven/claytext.rb', line 47

def content
  @content
end

#firstObject

Returns the value of attribute first.



47
48
49
# File 'lib/clayoven/claytext.rb', line 47

def first
  @first
end

#typeObject

Returns the value of attribute type.



47
48
49
# File 'lib/clayoven/claytext.rb', line 47

def type
  @type
end

Instance Method Details

#is_first?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/clayoven/claytext.rb', line 62

def is_first?
  @first
end