Class: Graphomaton::Transition

Inherits:
Data
  • Object
show all
Defined in:
lib/graphomaton/model.rb,
sig/graphomaton.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, from:, to:, label:, style:, metadata:, line_style:) ⇒ Transition

Returns a new instance of Transition.



164
165
166
167
168
169
170
171
172
173
174
# File 'lib/graphomaton/model.rb', line 164

def initialize(id:, from:, to:, label:, style:, metadata:, line_style:)
  super(
    id: id,
    from: ModelValue.copy(from),
    to: ModelValue.copy(to),
    label: ModelValue.copy(label),
    style: ModelValue.copy(style),
    metadata: ModelValue.copy(),
    line_style: ModelValue.copy(line_style)
  )
end

Instance Attribute Details

#from ⇒ Object (readonly)

Returns the value of attribute from

Returns:

  • (Object) —

    the current value of from



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def from
  @from
end

#id ⇒ Object (readonly)

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def id
  @id
end

#label ⇒ Object (readonly)

Returns the value of attribute label

Returns:

  • (Object) —

    the current value of label



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def label
  @label
end

#line_style ⇒ Object (readonly)

Returns the value of attribute line_style

Returns:

  • (Object) —

    the current value of line_style



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def line_style
  @line_style
end

#metadata ⇒ Object (readonly)

Returns the value of attribute metadata

Returns:

  • (Object) —

    the current value of metadata



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def 
  
end

#style ⇒ Object (readonly)

Returns the value of attribute style

Returns:

  • (Object) —

    the current value of style



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def style
  @style
end

#to ⇒ Object (readonly)

Returns the value of attribute to

Returns:

  • (Object) —

    the current value of to



163
164
165
# File 'lib/graphomaton/model.rb', line 163

def to
  @to
end

Instance Method Details

#[](key) ⇒ Object



176
177
178
179
180
# File 'lib/graphomaton/model.rb', line 176

def [](key)
  public_send(key)
rescue NoMethodError
  nil
end

#to_h ⇒ Object



182
183
184
185
186
187
188
# File 'lib/graphomaton/model.rb', line 182

def to_h
  output = { from: from, to: to, label: label.is_a?(Label) ? label.to_s : label }
  output[:style] = style unless style.nil?
  output[:metadata] =  unless .nil?
  output[:line_style] = line_style unless line_style.nil?
  output
end