Class: Flexibee::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, tree) ⇒ Node

Returns a new instance of Node.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/flexibee/node.rb', line 34

def initialize(response, tree)
  @id = response['id'].to_i
  @updated_at = response['lastUpdate']
  @code = response['kod']
  @name = response['nazev']
  @level = response['hladina'].to_i
  @order = response['poradi'].to_i
  @route = response['cesta']
  @short_description = response['kratkyPopis']
  @keywords = response['klicSlova']
  @description = response['popis']
  @tree_ref = response['strom@ref']
  @parent_id = response['otec'].to_i
  @parent_ref = response['otec@ref']
  @tree = tree
end

Instance Attribute Details

#codeObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def code
  @code
end

#descriptionObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def description
  @description
end

#idObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def id
  @id
end

#keywordsObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def keywords
  @keywords
end

#levelObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def level
  @level
end

#nameObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def name
  @name
end

#orderObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def order
  @order
end

#parent_idObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def parent_id
  @parent_id
end

#parent_refObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def parent_ref
  @parent_ref
end

#routeObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def route
  @route
end

#short_descriptionObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def short_description
  @short_description
end

#treeObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def tree
  @tree
end

#tree_refObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def tree_ref
  @tree_ref
end

#updated_atObject

}



31
32
33
# File 'lib/flexibee/node.rb', line 31

def updated_at
  @updated_at
end

Instance Method Details

#descendantsObject

all children of the node



54
55
56
# File 'lib/flexibee/node.rb', line 54

def descendants
  tree.children_of(id)
end

#parentObject

parent of the node



61
62
63
# File 'lib/flexibee/node.rb', line 61

def parent
  tree.parent_for(parent_id).first
end