Class: Atheme::Service::Command
- Inherits:
-
Object
- Object
- Atheme::Service::Command
- Defined in:
- lib/atheme/service.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(session, raw_output) ⇒ Object
-
#initialize(name, opts, &block) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(name, opts, &block) ⇒ Command
Returns a new instance of Command.
23 24 25 26 27 |
# File 'lib/atheme/service.rb', line 23 def initialize(name, opts, &block) @name = name @block = block @opts = opts end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
21 22 23 |
# File 'lib/atheme/service.rb', line 21 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/atheme/service.rb', line 21 def name @name end |
Instance Method Details
#call(session, raw_output) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/atheme/service.rb', line 29 def call(session, raw_output) @raw_output = raw_output value = self.instance_eval(&@block) return value if !@opts[:as] || value.nil? @opts[:as].new(session, value) end |