Class: LinkShrink::Options

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

Overview

Inherits from Hash to add predicate methods

Author:

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Options

Returns a new instance of Options.



5
6
7
8
# File 'lib/link_shrink/options.rb', line 5

def initialize(*args)
  super(*args)
  self.merge!(self.default)
end

Instance Method Details

#methodTrueclass

Dynamically defines three predicate methods

Returns:

  • (Trueclass)

    return true or false if no key found



12
13
14
15
16
# File 'lib/link_shrink/options.rb', line 12

[:qr_code, :json, :image_size].map do |method|
  define_method "#{method}?" do
    self.fetch(method, false)
  end
end