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.



152
153
154
155
156
157
158
159
160
161
162
# File 'lib/graphomaton/model.rb', line 152

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

#fromObject (readonly)

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def from
  @from
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def label
  @label
end

#line_styleObject (readonly)

Returns the value of attribute line_style

Returns:

  • (Object)

    the current value of line_style



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def line_style
  @line_style
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def 
  @metadata
end

#styleObject (readonly)

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def style
  @style
end

#toObject (readonly)

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



151
152
153
# File 'lib/graphomaton/model.rb', line 151

def to
  @to
end

Instance Method Details

#[](key) ⇒ Object



164
165
166
167
168
# File 'lib/graphomaton/model.rb', line 164

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

#to_hObject



170
171
172
173
174
175
176
# File 'lib/graphomaton/model.rb', line 170

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