Class: KwykTree::Unit
- Inherits:
-
Object
- Object
- KwykTree::Unit
- Defined in:
- lib/kwyktree/unit.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#deps ⇒ Object
readonly
Returns the value of attribute deps.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #graphviz_attributes ⇒ Object
- #graphviz_id ⇒ Object
- #graphviz_record_label ⇒ Object
- #graphviz_record_shape ⇒ Object
-
#initialize(unit) ⇒ Unit
constructor
A new instance of Unit.
- #type ⇒ Object
Constructor Details
#initialize(unit) ⇒ Unit
Returns a new instance of Unit.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kwyktree/unit.rb', line 6 def initialize(unit) if unit['name'] @name = unit['name'] else raise "unit needs a name" end @details = {} @details["anki"] = unit['anki'] || false @details["grok"] = unit['grok'] || false @desc = unit['desc'] || "" @url = unit['url'] if unit['url'] @deps = unit['deps'] || [] @deps.each do |l| l.downcase! end @title = unit['title'] || pretty_name end |
Instance Attribute Details
#deps ⇒ Object (readonly)
Returns the value of attribute deps.
5 6 7 |
# File 'lib/kwyktree/unit.rb', line 5 def deps @deps end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/kwyktree/unit.rb', line 5 def url @url end |
Instance Method Details
#graphviz_attributes ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/kwyktree/unit.rb', line 38 def graphviz_attributes hsh = { tooltip: @title, label: graphviz_record_label, shape: graphviz_record_shape } hsh[:URL] = @url if @url hsh end |
#graphviz_id ⇒ Object
34 35 36 |
# File 'lib/kwyktree/unit.rb', line 34 def graphviz_id "#{type}.#{@name.downcase.tr(' ', '_')}" end |
#graphviz_record_label ⇒ Object
29 30 31 32 |
# File 'lib/kwyktree/unit.rb', line 29 def graphviz_record_label # TODO: add desc "{#{@title}#{graphviz_details}}" end |
#graphviz_record_shape ⇒ Object
48 49 50 |
# File 'lib/kwyktree/unit.rb', line 48 def graphviz_record_shape raise "unit needs to be subclassed!" end |
#type ⇒ Object
25 26 27 |
# File 'lib/kwyktree/unit.rb', line 25 def type raise "unit needs to be subclassed!" end |