Class: RubyHome::CharacteristicTemplate
- Inherits:
-
Object
- Object
- RubyHome::CharacteristicTemplate
- Defined in:
- lib/ruby_home/factories/templates/characteristic_template.rb
Constant Summary collapse
- FILEPATH =
(File.dirname(__FILE__) + '/../../config/characteristics.yml').freeze
- DATA =
YAML.load_file(FILEPATH).freeze
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, description:, uuid:, format:, unit:, permissions:, properties:, constraints:) ⇒ CharacteristicTemplate
constructor
A new instance of CharacteristicTemplate.
- #to_hash ⇒ Object
Constructor Details
#initialize(name:, description:, uuid:, format:, unit:, permissions:, properties:, constraints:) ⇒ CharacteristicTemplate
Returns a new instance of CharacteristicTemplate.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 18 def initialize(name:, description:, uuid:, format:, unit:, permissions:, properties:, constraints:) @name = name @description = description @uuid = uuid @format = format @unit = unit @permissions = @properties = properties @constraints = constraints end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def constraints @constraints end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def description @description end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def name @name end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def @permissions end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def properties @properties end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def unit @unit end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
29 30 31 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 29 def uuid @uuid end |
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 6 def self.all @@all ||= DATA.map { |data| new(data) } end |
.find_by(options) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 10 def self.find_by() all.find do |characteristic| .all? do |key, value| characteristic.send(key) == value end end end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_home/factories/templates/characteristic_template.rb', line 31 def to_hash { name: name, description: description, uuid: uuid, format: format, unit: unit, properties: properties, } end |