Class: Moory::Transition::Shunter

Inherits:
Struct
  • Object
show all
Defined in:
lib/moory/transitions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#effectorObject

Returns the value of attribute effector

Returns:

  • (Object)

    the current value of effector



44
45
46
# File 'lib/moory/transitions.rb', line 44

def effector
  @effector
end

#originObject

Returns the value of attribute origin

Returns:

  • (Object)

    the current value of origin



44
45
46
# File 'lib/moory/transitions.rb', line 44

def origin
  @origin
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



44
45
46
# File 'lib/moory/transitions.rb', line 44

def output
  @output
end

#settlementObject

Returns the value of attribute settlement

Returns:

  • (Object)

    the current value of settlement



44
45
46
# File 'lib/moory/transitions.rb', line 44

def settlement
  @settlement
end

#stimulusObject

Returns the value of attribute stimulus

Returns:

  • (Object)

    the current value of stimulus



44
45
46
# File 'lib/moory/transitions.rb', line 44

def stimulus
  @stimulus
end

Instance Method Details

#to_hashObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/moory/transitions.rb', line 57

def to_hash
  return {} unless valid?

  p = Pair.new(left: origin, right: stimulus)

  p.shunt({ 
    settlement: settlement,
    output:     output,
    effector:   effector
  }.compact)
end

#valid?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/moory/transitions.rb', line 53

def valid?
  origin && stimulus && settlement
end