Class: SimplestStatus::StatusCollection
- Inherits:
-
Hash
- Object
- Hash
- SimplestStatus::StatusCollection
- Defined in:
- lib/simplest_status/status_collection.rb
Instance Method Summary collapse
- #[](status_name) ⇒ Object (also: #value_for)
- #add(status, value = self.size) ⇒ Object
- #each ⇒ Object
- #for_select ⇒ Object
- #label_for(value) ⇒ Object
- #status_for(input) ⇒ Object
Instance Method Details
#[](status_name) ⇒ Object Also known as: value_for
11 12 13 |
# File 'lib/simplest_status/status_collection.rb', line 11 def [](status_name) status_for(status_name).value end |
#add(status, value = self.size) ⇒ Object
22 23 24 |
# File 'lib/simplest_status/status_collection.rb', line 22 def add(status, value = self.size) self.merge!(status => value) end |
#each ⇒ Object
5 6 7 8 9 |
# File 'lib/simplest_status/status_collection.rb', line 5 def each super do |status| yield Status.new(status) end end |
#for_select ⇒ Object
30 31 32 |
# File 'lib/simplest_status/status_collection.rb', line 30 def for_select map(&:for_select) end |
#label_for(value) ⇒ Object
26 27 28 |
# File 'lib/simplest_status/status_collection.rb', line 26 def label_for(value) status_for(value).label end |
#status_for(input) ⇒ Object
16 17 18 19 20 |
# File 'lib/simplest_status/status_collection.rb', line 16 def status_for(input) find do |status| status.matches? input end end |