Class: Checklist::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/checklist/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(explain, list = nil, options = {}, &block) ⇒ Item

Returns a new instance of Item.



13
14
15
16
17
18
# File 'lib/checklist/item.rb', line 13

def initialize(explain, list = nil, options = {}, &block)
  @options = options
  @list = list
  @block = block
  @explain = explain
end

Instance Attribute Details

#explainObject (readonly)

Returns the value of attribute explain.



11
12
13
# File 'lib/checklist/item.rb', line 11

def explain
  @explain
end

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/checklist/item.rb', line 11

def key
  @key
end

#listObject (readonly)

Returns the value of attribute list.



11
12
13
# File 'lib/checklist/item.rb', line 11

def list
  @list
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/checklist/item.rb', line 11

def options
  @options
end

Instance Method Details

#checked?Boolean

Returns:

  • (Boolean)

Raises:



20
21
22
23
# File 'lib/checklist/item.rb', line 20

def checked?
  raise Checklist::InstanceMissingError unless list.context
  context.instance_eval(&@block) == true
end

#keep?Boolean

return true if the item should be checked

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/checklist/item.rb', line 26

def keep?
  keep = only_applies?
  keep = except_applies? if keep.nil?
  keep
end