Class: Archimate::DataModel::Layer

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/archimate/data_model/layer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer = "None", background_class = "") ⇒ Layer

No user serviceable parts here. don’t use me.



14
15
16
17
18
# File 'lib/archimate/data_model/layer.rb', line 14

def initialize(layer = "None", background_class = "")
  @symbol = Layer.symbolize(layer)
  @name = layer
  @background_class = background_class
end

Instance Attribute Details

#background_classObject (readonly)

Returns the value of attribute background_class.



11
12
13
# File 'lib/archimate/data_model/layer.rb', line 11

def background_class
  @background_class
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/archimate/data_model/layer.rb', line 10

def name
  @name
end

Class Method Details

.symbolize(str) ⇒ Object



54
55
56
57
# File 'lib/archimate/data_model/layer.rb', line 54

def self.symbolize(str)
  return str if str.is_a?(Symbol)
  str.downcase.tr(" ", "_").to_sym
end

Instance Method Details

#<=>(other) ⇒ Object



42
43
44
# File 'lib/archimate/data_model/layer.rb', line 42

def <=>(other)
  Layers.find_index(self) <=> Layers.find_index(other)
end

#==(other) ⇒ Object



38
39
40
# File 'lib/archimate/data_model/layer.rb', line 38

def ==(other)
  @symbol == other&.to_sym
end

#===(other) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/archimate/data_model/layer.rb', line 24

def ===(other)
  return true if equal?(other)
  case other
  when String
    @symbol == Layer.symbolize(other)
  when Symbol
    @symbol == other
  when Layer
    self == other
  else
    false
  end
end

#hashObject



20
21
22
# File 'lib/archimate/data_model/layer.rb', line 20

def hash
  self.class.hash ^ @symbol.hash
end

#to_sObject



50
51
52
# File 'lib/archimate/data_model/layer.rb', line 50

def to_s
  @name
end

#to_symObject



46
47
48
# File 'lib/archimate/data_model/layer.rb', line 46

def to_sym
  @symbol
end