Class: Graphomaton::State
- Inherits:
-
Data
- Object
- Data
- Graphomaton::State
- Defined in:
- lib/graphomaton/model.rb,
sig/graphomaton.rbs
Constant Summary collapse
- MISSING =
Object.new.freeze
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fetch(key, default = MISSING) ⇒ Object
-
#initialize(id:, x:, y:, label:, style:, metadata:, shape:, kind:) ⇒ State
constructor
A new instance of State.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, x:, y:, label:, style:, metadata:, shape:, kind:) ⇒ State
Returns a new instance of State.
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/graphomaton/model.rb', line 123 def initialize(id:, x:, y:, label:, style:, metadata:, shape:, kind:) super( id: ModelValue.copy(id), x: x, y: y, label: ModelValue.copy(label), style: ModelValue.copy(style), metadata: ModelValue.copy(), shape: ModelValue.copy(shape), kind: kind.nil? ? nil : kind.to_sym ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def kind @kind end |
#label ⇒ Object (readonly)
Returns the value of attribute label
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def label @label end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def @metadata end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def shape @shape end |
#style ⇒ Object (readonly)
Returns the value of attribute style
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def style @style end |
#x ⇒ Object (readonly)
Returns the value of attribute x
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y
120 121 122 |
# File 'lib/graphomaton/model.rb', line 120 def y @y end |
Instance Method Details
#[](key) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/graphomaton/model.rb', line 136 def [](key) return id if key == :name || key == :id public_send(key) rescue NoMethodError nil end |
#fetch(key, default = MISSING) ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/graphomaton/model.rb', line 144 def fetch(key, default = MISSING) value = self[key] return value unless value.nil? return default unless default.equal?(MISSING) raise KeyError, "key not found: #{key.inspect}" end |
#to_h ⇒ Object
152 153 154 155 156 157 158 159 160 |
# File 'lib/graphomaton/model.rb', line 152 def to_h output = { name: id, x: x, y: y } output[:label] = label unless label.nil? output[:style] = style unless style.nil? output[:metadata] = unless .nil? output[:shape] = shape unless shape.nil? output[:kind] = kind unless kind.nil? output end |