Class: Atheme::Service::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/atheme/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blockObject (readonly)

Returns the value of attribute block.



21
22
23
# File 'lib/atheme/service.rb', line 21

def block
  @block
end

#nameObject (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