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.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/graphomaton/model.rb', line 111 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
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def kind @kind end |
#label ⇒ Object (readonly)
Returns the value of attribute label
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def label @label end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def @metadata end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def shape @shape end |
#style ⇒ Object (readonly)
Returns the value of attribute style
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def style @style end |
#x ⇒ Object (readonly)
Returns the value of attribute x
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y
108 109 110 |
# File 'lib/graphomaton/model.rb', line 108 def y @y end |
Instance Method Details
#[](key) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/graphomaton/model.rb', line 124 def [](key) return id if key == :name || key == :id public_send(key) rescue NoMethodError nil end |
#fetch(key, default = MISSING) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/graphomaton/model.rb', line 132 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
140 141 142 143 144 145 146 147 148 |
# File 'lib/graphomaton/model.rb', line 140 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 |