Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/hard_boiled/blank.rb,
lib/hard_boiled/extract_options.rb
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Synonym for #empty?.
-
#extract_options! ⇒ Object
Extracts options from a set of arguments.
Instance Method Details
#blank? ⇒ Boolean
Synonym for #empty?
3 4 5 |
# File 'lib/hard_boiled/blank.rb', line 3 def blank? self.empty? end |
#extract_options! ⇒ Object
Extracts options from a set of arguments. Removes and returns the last element in the array if it’s a hash, otherwise returns a blank hash.
def (*args)
args.
end
(1, 2) # => {}
(1, 2, :a => :b) # => {:a=>:b}
25 26 27 28 29 30 31 |
# File 'lib/hard_boiled/extract_options.rb', line 25 def if last.is_a?(Hash) && last. pop else {} end end |