Class: JLDrill::ItemStatus
- Inherits:
-
Object
- Object
- JLDrill::ItemStatus
- Defined in:
- lib/jldrill/model/ItemStatus.rb
Overview
A container to hold the status of each kind of drill for the item.
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#statuses ⇒ Object
readonly
Returns the value of attribute statuses.
Instance Method Summary collapse
- #add(status) ⇒ Object
- #assign(itemStatus) ⇒ Object
-
#initialize(item) ⇒ ItemStatus
constructor
A new instance of ItemStatus.
- #parse(part) ⇒ Object
- #select(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(item) ⇒ ItemStatus
Returns a new instance of ItemStatus.
10 11 12 13 |
# File 'lib/jldrill/model/ItemStatus.rb', line 10 def initialize(item) @item = item @statuses = {} end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
8 9 10 |
# File 'lib/jldrill/model/ItemStatus.rb', line 8 def item @item end |
#statuses ⇒ Object (readonly)
Returns the value of attribute statuses.
8 9 10 |
# File 'lib/jldrill/model/ItemStatus.rb', line 8 def statuses @statuses end |
Instance Method Details
#add(status) ⇒ Object
15 16 17 |
# File 'lib/jldrill/model/ItemStatus.rb', line 15 def add(status) @statuses[status.name] = status end |
#assign(itemStatus) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/jldrill/model/ItemStatus.rb', line 19 def assign(itemStatus) itemStatus.statuses.each_value do |status| newStatus = status.clone newStatus.item = @item add(status.clone) end end |
#parse(part) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jldrill/model/ItemStatus.rb', line 31 def parse(part) parsed = false statuses = @statuses.values i = 0 while (i < statuses.size) && (!parsed) parsed = statuses[i].parse(part) i += 1 end return parsed end |
#select(name) ⇒ Object
27 28 29 |
# File 'lib/jldrill/model/ItemStatus.rb', line 27 def select(name) return @statuses[name] end |
#to_s ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/jldrill/model/ItemStatus.rb', line 42 def to_s retVal = "" statuses.keys().sort.each do |key| retVal += statuses[key].to_s end return retVal end |