Class: Tweetwine::Options
- Inherits:
-
Object
- Object
- Tweetwine::Options
- Defined in:
- lib/tweetwine/options.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(options, source = nil) ⇒ Options
constructor
A new instance of Options.
- #require(key) ⇒ Object
Constructor Details
#initialize(options, source = nil) ⇒ Options
Returns a new instance of Options.
3 4 5 6 |
# File 'lib/tweetwine/options.rb', line 3 def initialize(, source = nil) @hash = .to_hash @source = source end |
Instance Method Details
#[](key) ⇒ Object
8 9 10 |
# File 'lib/tweetwine/options.rb', line 8 def [](key) @hash[key] end |
#require(key) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/tweetwine/options.rb', line 12 def require(key) value = @hash[key] if value.nil? msg = "Option #{key} is required" msg << " for #{@source}" if @source raise ArgumentError, msg end value end |