Class: Checklist::Item
- Inherits:
-
Object
- Object
- Checklist::Item
- Defined in:
- lib/checklist/item.rb
Instance Attribute Summary collapse
-
#explain ⇒ Object
readonly
Returns the value of attribute explain.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #checked? ⇒ Boolean
-
#initialize(explain, list = nil, options = {}, &block) ⇒ Item
constructor
A new instance of Item.
-
#keep? ⇒ Boolean
return true if the item should be checked.
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, = {}, &block) @options = @list = list @block = block @explain = explain end |
Instance Attribute Details
#explain ⇒ Object (readonly)
Returns the value of attribute explain.
11 12 13 |
# File 'lib/checklist/item.rb', line 11 def explain @explain end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/checklist/item.rb', line 11 def key @key end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
11 12 13 |
# File 'lib/checklist/item.rb', line 11 def list @list end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/checklist/item.rb', line 11 def @options end |
Instance Method Details
#checked? ⇒ Boolean
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
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 |