Class: BBMB::Html::State::Result::Result

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bbmb/html/state/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, products) ⇒ Result

Returns a new instance of Result.



14
15
16
# File 'lib/bbmb/html/state/result.rb', line 14

def initialize(order, products)
  @order, @products = order, products
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



13
14
15
# File 'lib/bbmb/html/state/result.rb', line 13

def order
  @order
end

#productsObject (readonly)

Returns the value of attribute products.



13
14
15
# File 'lib/bbmb/html/state/result.rb', line 13

def products
  @products
end

Instance Method Details

#each(&block) ⇒ Object



17
18
19
# File 'lib/bbmb/html/state/result.rb', line 17

def each(&block)
  @products.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bbmb/html/state/result.rb', line 20

def empty?
  @products.empty?
end

#ordered_quantity(article_number) ⇒ Object



23
24
25
# File 'lib/bbmb/html/state/result.rb', line 23

def ordered_quantity(article_number)
  @order.quantity(article_number)
end

#quota(article_id) ⇒ Object



26
27
28
# File 'lib/bbmb/html/state/result.rb', line 26

def quota(article_id)
  @order.quota(article_id)
end

#reverse!Object



29
30
31
# File 'lib/bbmb/html/state/result.rb', line 29

def reverse!
  @products.reverse!
end

#sizeObject



32
33
34
# File 'lib/bbmb/html/state/result.rb', line 32

def size
  @products.size
end

#sort!(*args, &block) ⇒ Object



39
40
41
# File 'lib/bbmb/html/state/result.rb', line 39

def sort!(*args, &block)
  @products.sort!(*args, &block)
end

#sort_by(&block) ⇒ Object



35
36
37
38
# File 'lib/bbmb/html/state/result.rb', line 35

def sort_by(&block)
  @products = @products.sort_by(&block)
  self
end