Class: Automatic::OPML::DOM::Element

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

Direct Known Subclasses

Body, Head, OPML, Outline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeElement

Returns a new instance of Element.



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

def initialize
  @attr = {}
  @parent = nil
  @children = []
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



40
41
42
# File 'lib/automatic/opml.rb', line 40

def attr
  @attr
end

#childrenObject (readonly)

Returns the value of attribute children.



40
41
42
# File 'lib/automatic/opml.rb', line 40

def children
  @children
end

#parentObject

Returns the value of attribute parent.



39
40
41
# File 'lib/automatic/opml.rb', line 39

def parent
  @parent
end

Instance Method Details

#<<(elem) ⇒ Object



51
52
53
54
55
# File 'lib/automatic/opml.rb', line 51

def <<(elem)
  elem.parent = self if elem.respond_to? :parent=
    @children << elem
  self
end

#[](n) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/automatic/opml.rb', line 57

def [](n)
  if n.is_a? String
  @attr[n]
  else
    @children[n]
  end
end

#[]=(k, v) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/automatic/opml.rb', line 65

def []=(k,v)
  if k.is_a? String
    @attr[k] = v
  else
    @children[k] = v
  end
end

#each {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



42
43
44
45
46
47
48
49
# File 'lib/automatic/opml.rb', line 42

def each
  yield self
  @children.each {|c|
    c.each {|x|
      yield x
    }
  }
end

#is_breaakpoint?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/automatic/opml.rb', line 85

def is_breaakpoint?
  @attr['isBreakpoint']=='true'
end

#is_comment?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/automatic/opml.rb', line 81

def is_comment?
  @attr['isComment']=='true'
end

#textObject



73
74
75
# File 'lib/automatic/opml.rb', line 73

def text
  @attr['text']
end

#typeObject



77
78
79
# File 'lib/automatic/opml.rb', line 77

def type
  @attr['type']
end