Class: Rubot::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/rubot/classes/command.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(execute, name:) ⇒ Command
7
8
9
10
|
# File 'lib/rubot/classes/command.rb', line 7
def initialize(execute, name:)
@props = Hash[:name => name]
@execute = execute
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *_args) ⇒ Object
20
21
22
|
# File 'lib/rubot/classes/command.rb', line 20
def method_missing(symbol, *_args)
@props[symbol] || super
end
|
Instance Attribute Details
#execute ⇒ Object
Returns the value of attribute execute.
5
6
7
|
# File 'lib/rubot/classes/command.rb', line 5
def execute
@execute
end
|
#props ⇒ Object
Returns the value of attribute props.
5
6
7
|
# File 'lib/rubot/classes/command.rb', line 5
def props
@props
end
|
Instance Method Details
#[](prop) ⇒ Object
12
13
14
|
# File 'lib/rubot/classes/command.rb', line 12
def [](prop)
@props[prop.to_sym]
end
|
#[]=(prop, value) ⇒ Object
16
17
18
|
# File 'lib/rubot/classes/command.rb', line 16
def []=(prop, value)
@props[prop.to_sym] = value
end
|
#respond_to_missing?(symbol, _include_private = false) ⇒ Boolean
24
25
26
|
# File 'lib/rubot/classes/command.rb', line 24
def respond_to_missing?(symbol, _include_private = false)
!!@props[symbol] || super
end
|