Class: Eprayim::Element
- Inherits:
-
Object
- Object
- Eprayim::Element
- Defined in:
- lib/eprayim/element.rb,
lib/eprayim/render/html.rb
Constant Summary collapse
- TYPES =
%w{ doc head para quote code list olist hr bold strong deleted italic icode image link }.map(&:to_sym)
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, *args) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(type, *args) ⇒ Element
Returns a new instance of Element.
10 11 12 13 14 |
# File 'lib/eprayim/element.rb', line 10 def initialize(type, *args) @type = type.to_sym @children = args || [] raise "Bad element type: #{@type}" if not TYPES.include? @type end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
8 9 10 |
# File 'lib/eprayim/element.rb', line 8 def children @children end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/eprayim/element.rb', line 7 def type @type end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 19 20 |
# File 'lib/eprayim/element.rb', line 16 def ==(other) return self.type == other.type && self.children == other.children rescue return false end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/eprayim/element.rb', line 22 def inspect "#{self.type}: #{self.children}" end |
#to_html ⇒ Object
30 31 32 |
# File 'lib/eprayim/render/html.rb', line 30 def to_html @html ||= Render::HTML.render(self) end |