Class: Gratitude::UserChart
- Inherits:
-
Object
- Object
- Gratitude::UserChart
- Extended by:
- Connection
- Defined in:
- lib/gratitude/user_chart.rb
Constant Summary collapse
- USER_CHARTS =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#number_of_patrons ⇒ Object
(also: #npatrons)
readonly
Returns the value of attribute number_of_patrons.
-
#receipts ⇒ Object
readonly
Returns the value of attribute receipts.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ UserChart
constructor
A new instance of UserChart.
Methods included from Connection
Constructor Details
#initialize(options = {}) ⇒ UserChart
Returns a new instance of UserChart.
11 12 13 14 15 16 17 |
# File 'lib/gratitude/user_chart.rb', line 11 def initialize( = {}) @username = ["username"] @date = Date.parse(["date"]) if ["date"] @number_of_patrons = ["npatrons"] @receipts = ["receipts"] USER_CHARTS << self end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'lib/gratitude/user_chart.rb', line 8 def date @date end |
#number_of_patrons ⇒ Object (readonly) Also known as: npatrons
Returns the value of attribute number_of_patrons.
8 9 10 |
# File 'lib/gratitude/user_chart.rb', line 8 def number_of_patrons @number_of_patrons end |
#receipts ⇒ Object (readonly)
Returns the value of attribute receipts.
8 9 10 |
# File 'lib/gratitude/user_chart.rb', line 8 def receipts @receipts end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/gratitude/user_chart.rb', line 8 def username @username end |
Class Method Details
.all_for_user(username) ⇒ Object
19 20 21 22 23 |
# File 'lib/gratitude/user_chart.rb', line 19 def self.all_for_user(username) USER_CHARTS.clear if user_charts_contains_other_usernames?(username) collect_charts_for(username) if USER_CHARTS.empty? USER_CHARTS end |
.newest_for(username) ⇒ Object
25 26 27 |
# File 'lib/gratitude/user_chart.rb', line 25 def self.newest_for(username) sort_by_date_for_user(username).first end |
.oldest_for(username) ⇒ Object
29 30 31 |
# File 'lib/gratitude/user_chart.rb', line 29 def self.oldest_for(username) sort_by_date_for_user(username).last end |