Class: Opml::Outline

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ Outline

Returns a new instance of Outline.



18
19
20
21
# File 'lib/opml.rb', line 18

def initialize(element)
  @attributes = map_attributes_to_hash(element.attributes)
  @outlines = element.elements.map { |element| Outline.new(element) }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
# File 'lib/opml.rb', line 36

def method_missing(method, *args, &block)
  attributes[method.to_s] || super
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



16
17
18
# File 'lib/opml.rb', line 16

def attributes
  @attributes
end

#outlinesObject

Returns the value of attribute outlines.



16
17
18
# File 'lib/opml.rb', line 16

def outlines
  @outlines
end

Instance Method Details

#flattenObject



23
24
25
# File 'lib/opml.rb', line 23

def flatten
  @flatten ||= @outlines.map(&:flatten).unshift(self)
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/opml.rb', line 31

def respond_to?(method)
  return true if attributes[method.to_s]
  super
end

#to_sObject



27
28
29
# File 'lib/opml.rb', line 27

def to_s
  @to_s ||= attributes['text'] || super
end