Class: Collins::PowerUnit

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/collins/power.rb

Constant Summary

Constants included from Util::Logging

Util::Logging::DEFAULT_LOG_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#get_logger

Constructor Details

#initialize(model = {}) ⇒ PowerUnit

Returns a new instance of PowerUnit.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/collins/power.rb', line 12

def initialize model = {}
  hash = symbolize_hash(model).inject({}) do |result, (k,v)|
    result[k.downcase] = v
    result
  end
  @key = hash[:key].to_s
  @value = hash[:value].to_s
  @type = hash[:type].to_s
  @label = hash[:label].to_s
  @position = hash[:position].to_s.to_i
  @is_required = hash[:is_required]
  @unique = hash[:unique]
end

Instance Attribute Details

#is_requiredObject

Returns the value of attribute is_required.



10
11
12
# File 'lib/collins/power.rb', line 10

def is_required
  @is_required
end

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/collins/power.rb', line 10

def key
  @key
end

#labelObject

Returns the value of attribute label.



10
11
12
# File 'lib/collins/power.rb', line 10

def label
  @label
end

#positionObject

Returns the value of attribute position.



10
11
12
# File 'lib/collins/power.rb', line 10

def position
  @position
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/collins/power.rb', line 10

def type
  @type
end

#uniqueObject

Returns the value of attribute unique.



10
11
12
# File 'lib/collins/power.rb', line 10

def unique
  @unique
end

#valueObject

Returns the value of attribute value.



10
11
12
# File 'lib/collins/power.rb', line 10

def value
  @value
end

Instance Method Details

#is_required?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/collins/power.rb', line 26

def is_required?
  @is_required == true
end

#unique?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/collins/power.rb', line 29

def unique?
  @unique == true
end