Class: Intersail::Rpdf::Node
- Inherits:
-
Object
- Object
- Intersail::Rpdf::Node
- Defined in:
- lib/rpdf/models/node.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #children ⇒ Object
- #has_children? ⇒ Boolean
-
#initialize(hash) ⇒ Node
constructor
A new instance of Node.
- #name ⇒ Object
Constructor Details
#initialize(hash) ⇒ Node
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rpdf/models/node.rb', line 18 def initialize(hash) @hash = hash @name = hash[:name] = hash[:childs][:tag_node] if hash[:childs] && hash[:childs][:tag_node] if .kind_of? Array @children = .map{|c| Node.new(c)} elsif .kind_of? Hash @children = [Node.new()] end end |
Instance Method Details
#[](index) ⇒ Object
14 15 16 |
# File 'lib/rpdf/models/node.rb', line 14 def [](index) @hash[index] end |
#children ⇒ Object
7 8 9 |
# File 'lib/rpdf/models/node.rb', line 7 def children @children end |
#has_children? ⇒ Boolean
10 11 12 |
# File 'lib/rpdf/models/node.rb', line 10 def has_children? @children && @children.respond_to?(:length) && @children.length>0 end |
#name ⇒ Object
4 5 6 |
# File 'lib/rpdf/models/node.rb', line 4 def name @name end |