Class: TwentyFortyEight::Options
- Inherits:
-
Object
- Object
- TwentyFortyEight::Options
show all
- Defined in:
- lib/TwentyFortyEight/options.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
4
5
6
|
# File 'lib/TwentyFortyEight/options.rb', line 4
def initialize(options = {})
@options = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
12
13
14
15
|
# 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
|
Instance Method Details
#[](key) ⇒ Object
8
9
10
|
# File 'lib/TwentyFortyEight/options.rb', line 8
def [](key)
@options[key]
end
|
#merge(other) ⇒ Object
21
22
23
|
# File 'lib/TwentyFortyEight/options.rb', line 21
def merge(other)
@options.merge! other
end
|
#respond_to_missing?(sym, *args, &block) ⇒ Boolean
17
18
19
|
# File 'lib/TwentyFortyEight/options.rb', line 17
def respond_to_missing?(sym, *args, &block)
option? sym
end
|
#to_a ⇒ Object
29
30
31
|
# File 'lib/TwentyFortyEight/options.rb', line 29
def to_a
@options.to_a
end
|
#to_hash ⇒ Object
25
26
27
|
# File 'lib/TwentyFortyEight/options.rb', line 25
def to_hash
@options
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/TwentyFortyEight/options.rb', line 33
def to_s
@options.to_s
end
|