Class: Action

Inherits:
Object
  • Object
show all
Defined in:
lib/cisco-deviot/thing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, need_payload = false) ⇒ Action

Returns a new instance of Action.



63
64
65
66
67
# File 'lib/cisco-deviot/thing.rb', line 63

def initialize(name, need_payload = false)
  @name = name
  @parameters = []
  @need_payload = need_payload
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



59
60
61
# File 'lib/cisco-deviot/thing.rb', line 59

def name
  @name
end

#need_payloadObject (readonly)

Returns the value of attribute need_payload.



61
62
63
# File 'lib/cisco-deviot/thing.rb', line 61

def need_payload
  @need_payload
end

#parametersObject (readonly)

Returns the value of attribute parameters.



60
61
62
# File 'lib/cisco-deviot/thing.rb', line 60

def parameters
  @parameters
end

Instance Method Details

#add_parameter(parameter) ⇒ Object

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cisco-deviot/thing.rb', line 69

def add_parameter(parameter)
  if parameter.instance_of? String
    @parameters.push(Property.new(parameter))
    return self
  end
  if parameter.instance_of? Property
    @parameters.push(parameter)
    return self
  end
  raise ArgumentError
end

#get_modelObject



81
82
83
# File 'lib/cisco-deviot/thing.rb', line 81

def get_model
  {name: @name, parameters: @parameters.collect {|p| p.get_model}}
end