Class: Fable::InkList::InkListItem
- Inherits:
-
Object
- Object
- Fable::InkList::InkListItem
- Defined in:
- lib/fable/ink_list.rb
Overview
The underlying type for a list item in ink. It stores the original list definition name as well as the item name, but without the value of the item. When the value is stored, it’s stored in a Dictionary of InkListItem and an integer.
Instance Attribute Summary collapse
-
#item_name ⇒ Object
The main name of the item as defined in ink.
-
#origin_name ⇒ Object
The name of the list where the item was originally defined.
Class Method Summary collapse
Instance Method Summary collapse
- #equal?(other_object) ⇒ Boolean
-
#full_name ⇒ Object
(also: #to_s)
Get the full dot-separated name of the item, in the form of ‘list_definition_name.list_item_name`.
-
#initialize(options) ⇒ InkListItem
constructor
A new instance of InkListItem.
- #null_item? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ InkListItem
Returns a new instance of InkListItem.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fable/ink_list.rb', line 16 def initialize() # Create an item from a dot-separated string of the form # `list_definition_name.list_item_name` if .has_key?(:full_name) name_parts = [:full_name].split(".") self.origin_name = name_parts[0] self.item_name = name_parts[1] else self.origin_name = [:origin_name] self.item_name = [:item_name] end end |
Instance Attribute Details
#item_name ⇒ Object
The main name of the item as defined in ink
14 15 16 |
# File 'lib/fable/ink_list.rb', line 14 def item_name @item_name end |
#origin_name ⇒ Object
The name of the list where the item was originally defined.
11 12 13 |
# File 'lib/fable/ink_list.rb', line 11 def origin_name @origin_name end |
Class Method Details
.Null ⇒ Object
29 30 31 |
# File 'lib/fable/ink_list.rb', line 29 def self.Null return self.new(origin_name: nil, item_name: nil) end |
Instance Method Details
#equal?(other_object) ⇒ Boolean
45 46 47 48 49 50 51 52 |
# File 'lib/fable/ink_list.rb', line 45 def equal?(other_object) return false if !other_object.is_a?(InkListItem) return ( other_object.item_name == self.item_name && other_object.origin_name == self.origin_name ) end |
#full_name ⇒ Object Also known as: to_s
Get the full dot-separated name of the item, in the form of ‘list_definition_name.list_item_name`
39 40 41 |
# File 'lib/fable/ink_list.rb', line 39 def full_name return "#{origin_name.nil? ? "?" : origin_name}.#{item_name}" end |
#null_item? ⇒ Boolean
33 34 35 |
# File 'lib/fable/ink_list.rb', line 33 def null_item? origin_name.nil? && item_name.null? end |