Class: Ragol::Results

Inherits:
Object
  • Object
show all
Includes:
Logue::Loggable
Defined in:
lib/ragol/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, args = Array.new) ⇒ Results

Returns a new instance of Results.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ragol/results.rb', line 14

def initialize options, args = Array.new
  @argslist = Ragol::ArgsList.new(args)
  @values = Hash.new

  options.each do |option|
    @values[option.name] = option.default
    
    define_singleton_method option.name do
      instance_eval do
        @values[option.name]
      end
    end
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/ragol/results.rb', line 12

def options
  @options
end

Instance Method Details

#argsObject



49
50
51
# File 'lib/ragol/results.rb', line 49

def args
  @argslist.args
end

#args_empty?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/ragol/results.rb', line 61

def args_empty?
  @argslist.args_empty?
end

#current_argObject



65
66
67
# File 'lib/ragol/results.rb', line 65

def current_arg
  @argslist.current_arg
end

#end_of_options?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ragol/results.rb', line 45

def end_of_options?
  @argslist.end_of_options?
end

#next_argObject



53
54
55
# File 'lib/ragol/results.rb', line 53

def next_arg
  @argslist.next_arg
end

#set_value(optname, value) ⇒ Object



33
34
35
# File 'lib/ragol/results.rb', line 33

def set_value optname, value
  @values[optname] = value
end

#shift_argObject



57
58
59
# File 'lib/ragol/results.rb', line 57

def shift_arg
  @argslist.shift_arg
end

#unprocessedObject



41
42
43
# File 'lib/ragol/results.rb', line 41

def unprocessed
  @argslist
end

#unset_value(optname) ⇒ Object



37
38
39
# File 'lib/ragol/results.rb', line 37

def unset_value optname
  @values.delete optname
end

#value(optname) ⇒ Object



29
30
31
# File 'lib/ragol/results.rb', line 29

def value optname
  @values[optname]
end