Class: Collins::AssetState
- Inherits:
-
Object
- Object
- Collins::AssetState
- Includes:
- Util
- Defined in:
- lib/collins/state.rb
Constant Summary
Constants included from Util::Logging
Util::Logging::DEFAULT_LOG_FORMAT
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(opts = {}) ⇒ AssetState
constructor
A new instance of AssetState.
- #to_s ⇒ Object
Methods included from Util
#deep_copy_hash, #get_asset_or_tag, included, #require_non_empty, #require_that, #stringify_hash, #symbolize_hash
Methods included from Util::Logging
Constructor Details
#initialize(opts = {}) ⇒ AssetState
Returns a new instance of AssetState.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/collins/state.rb', line 13 def initialize opts = {} hash = symbolize_hash(opts).inject({}) do |result, (k,v)| key = k.to_s.downcase.to_sym result[key] = v result end @description = hash[:description].to_s @id = hash[:id].to_s.to_i @label = hash[:label].to_s @name = hash[:name].to_s @status = get_status hash[:status] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/collins/state.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/collins/state.rb', line 7 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/collins/state.rb', line 7 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/collins/state.rb', line 7 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/collins/state.rb', line 7 def status @status end |
Class Method Details
.from_json(json) ⇒ Object
9 10 11 |
# File 'lib/collins/state.rb', line 9 def self.from_json json Collins::AssetState.new json end |
Instance Method Details
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/collins/state.rb', line 26 def empty? @id == 0 end |
#to_s ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/collins/state.rb', line 30 def to_s if empty? then "State(None)" else "State(id = #{id}, name = '#{name}', label = '#{label}', description = '#{description}')" end end |