class TwentyFortyEight::Options

Options

Public Class Methods

new(options = {}) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 4
def initialize(options = {})
  @options = options
end

Public Instance Methods

[](key) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 8
def [](key)
  @options[key]
end
merge(other) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 21
def merge(other)
  @options.merge! other
  self
end
method_missing(sym, *args, &block) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 12
def method_missing(sym, *args, &block)
  return @options[to_option(sym)] == args.first if args.any?
  @options[to_option(sym)]
end
respond_to_missing?(sym, *args, &block) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 17
def respond_to_missing?(sym, *args, &block)
  option? sym
end
to_a() click to toggle source
# File lib/TwentyFortyEight/options.rb, line 30
def to_a
  @options.to_a
end
to_hash() click to toggle source
# File lib/TwentyFortyEight/options.rb, line 26
def to_hash
  @options
end
to_s() click to toggle source
# File lib/TwentyFortyEight/options.rb, line 34
def to_s
  @options.to_s
end

Private Instance Methods

option?(sym) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 44
def option?(sym)
  @options.keys.include? to_option(sym)
end
to_option(sym) click to toggle source
# File lib/TwentyFortyEight/options.rb, line 40
def to_option(sym)
  sym.to_s.tr('?', '').to_sym
end