Class: SomethingAndNothing::ListDisplayHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/something_and_nothing/list_display_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ ListDisplayHelper

Returns a new instance of ListDisplayHelper.



5
6
7
# File 'lib/something_and_nothing/list_display_helper.rb', line 5

def initialize(list)
  @list = list
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



3
4
5
# File 'lib/something_and_nothing/list_display_helper.rb', line 3

def list
  @list
end

Instance Method Details

#more_than_oneObject



21
22
23
# File 'lib/something_and_nothing/list_display_helper.rb', line 21

def more_than_one
  yield if block_given? && @list.length > 1
end

#populatedObject



9
10
11
# File 'lib/something_and_nothing/list_display_helper.rb', line 9

def populated
  yield if block_given? && @list.length > 0
end

#singleObject



17
18
19
# File 'lib/something_and_nothing/list_display_helper.rb', line 17

def single
  yield if block_given? && @list.length == 1
end

#unpopulatedObject



13
14
15
# File 'lib/something_and_nothing/list_display_helper.rb', line 13

def unpopulated
  yield if block_given? && @list.length == 0
end