Class: FlavourSaver::Helpers::Defaults
- Inherits:
-
Object
- Object
- FlavourSaver::Helpers::Defaults
- Defined in:
- lib/flavour_saver/helpers.rb
Direct Known Subclasses
Instance Method Summary collapse
- #each(collection) ⇒ Object
- #if(truthy) ⇒ Object
- #log(message) ⇒ Object
- #this ⇒ Object
- #unless(falsy, &b) ⇒ Object
- #with(args) ⇒ Object
Instance Method Details
#each(collection) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flavour_saver/helpers.rb', line 10 def each(collection) r = [] count = 0 collection.each do |element| r << yield.contents(element, 'index' => count, 'last' => count == collection.size - 1, 'first' => count == 0) count += 1 end yield.rendered! r.join '' end |
#if(truthy) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/flavour_saver/helpers.rb', line 24 def if(truthy) truthy = false if truthy.respond_to?(:size) && (truthy.size == 0) if truthy yield.contents else yield.inverse end end |
#log(message) ⇒ Object
41 42 43 44 |
# File 'lib/flavour_saver/helpers.rb', line 41 def log() FS.logger.debug("FlavourSaver: #{}") '' end |
#this ⇒ Object
37 38 39 |
# File 'lib/flavour_saver/helpers.rb', line 37 def this @source || self end |
#unless(falsy, &b) ⇒ Object
33 34 35 |
# File 'lib/flavour_saver/helpers.rb', line 33 def unless(falsy,&b) self.if(!falsy,&b) end |
#with(args) ⇒ Object
6 7 8 |
# File 'lib/flavour_saver/helpers.rb', line 6 def with(args) yield.contents args end |