Class: Tweetwine::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/tweetwine/options.rb

Instance Method Summary collapse

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(options, source = nil)
  @hash = options.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