Class: Habdsl::Model::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/habdsl/model/point.rb

Overview

Represents a point in the model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, label:, type:, icon:, tags:, parent: nil, channel: nil) ⇒ Point

Returns a new instance of Point.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/habdsl/model/point.rb', line 9

def initialize(name:, label:, type:, icon:, tags:, parent: nil, channel: nil)
  validate!(name, "name")
  validate!(type, "type")
  validate!(icon, "icon")

  @name = name
  @label = label
  @type = type
  @icon = icon
  @tags = tags
  @parent = parent
  @channel = channel
end

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def icon
  @icon
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def parent
  @parent
end

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def tags
  @tags
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/habdsl/model/point.rb', line 7

def type
  @type
end

Instance Method Details

#equipmentObject



27
28
29
# File 'lib/habdsl/model/point.rb', line 27

def equipment(*)
  raise "Error: equipment cannot be nested inside point"
end

#locationObject



23
24
25
# File 'lib/habdsl/model/point.rb', line 23

def location(*)
  raise "Error: location cannot be nested inside point"
end

#to_s(parent_name = nil) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/habdsl/model/point.rb', line 31

def to_s(parent_name = nil)
  result = "#{@type} #{@name} \"#{@label}\" <#{@icon}>"
  result += format_parent(parent_name, @parent)
  result += " [#{@tags.map {|t| "\"#{t}\"" }.join(', ')}]"
  result += " {channel=\"#{@channel}\"}" if @channel
  result += "\n"
  result
end