class Cartos::Cashbase::Collection
Attributes
elements[RW]
Public Instance Methods
categories()
click to toggle source
# File lib/cartos/cashbase.rb, line 33 def categories result = self.elements.inject([]) do |memo, element| memo << element.category end result.uniq end
each(&block)
click to toggle source
# File lib/cartos/cashbase.rb, line 85 def each(&block) self.elements.each &block if block_given? end
each_category() { |category, elements| ... }
click to toggle source
# File lib/cartos/cashbase.rb, line 65 def each_category(&block) categories_hash = self.elements.inject({}) do |memo, element| (memo[element.category] ||= []) << element memo end categories_hash.each_pair do |category, elements| collection = self.class.new collection.elements = elements yield category, elements end end
each_month() { |month, collection| ... }
click to toggle source
# File lib/cartos/cashbase.rb, line 52 def each_month(&block) months_hash = self.elements.inject({}) do |memo, element| (memo[element.date.month] ||= []) << element memo end months_hash.each_pair do |month, elements| collection = self.class.new collection.elements = elements yield month, collection end end
filter_by_month(month)
click to toggle source
# File lib/cartos/cashbase.rb, line 78 def filter_by_month(month) self.elements.select! do |element| element.date.month == month end self end
filter_by_year(year)
click to toggle source
# File lib/cartos/cashbase.rb, line 45 def filter_by_year(year) self.elements.select! do |element| element.date.year == year end self end
size()
click to toggle source
# File lib/cartos/cashbase.rb, line 41 def size self.elements.size end
to_a()
click to toggle source
# File lib/cartos/cashbase.rb, line 89 def to_a self.elements end