Class: BeerList::List

Inherits:
Array
  • Object
show all
Defined in:
lib/beer_list/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ List

Returns a new instance of List.



5
6
7
8
9
# File 'lib/beer_list/list.rb', line 5

def initialize(opts={})
  ary            = opts[:array] || []
  @establishment = opts[:establishment]
  super ary.sort
end

Instance Attribute Details

#establishmentObject (readonly)

Returns the value of attribute establishment.



3
4
5
# File 'lib/beer_list/list.rb', line 3

def establishment
  @establishment
end

Instance Method Details

#old_to_jsonObject



15
# File 'lib/beer_list/list.rb', line 15

alias :old_to_json :to_json

#to_hashObject



11
12
13
# File 'lib/beer_list/list.rb', line 11

def to_hash
  Hash[establishment, self.to_a]
end

#to_jsonObject



17
18
19
# File 'lib/beer_list/list.rb', line 17

def to_json
  to_hash.to_json
end