Class: Collins::AssetType
- Inherits:
-
Object
- Object
- Collins::AssetType
- Includes:
- Util
- Defined in:
- lib/collins/asset_type.rb
Constant Summary
Constants included from Util::Logging
Util::Logging::DEFAULT_LOG_FORMAT
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(opts = {}) ⇒ AssetType
constructor
A new instance of AssetType.
- #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 = {}) ⇒ AssetType
Returns a new instance of AssetType.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/collins/asset_type.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 @id = hash[:id].to_s.to_i @label = hash[:label].to_s @name = hash[:name].to_s end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/collins/asset_type.rb', line 7 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/collins/asset_type.rb', line 7 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/collins/asset_type.rb', line 7 def name @name end |
Class Method Details
Instance Method Details
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/collins/asset_type.rb', line 24 def empty? @id == 0 end |
#to_s ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/collins/asset_type.rb', line 28 def to_s if empty? then "AssetType(None)" else "AssetType(id = #{id}, name = '#{name}', label = '#{label}')" end end |