Class: Moodwall::Mood
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Record
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, current: false) ⇒ Mood
constructor
A new instance of Mood.
Methods inherited from Record
#==, all, #delete, find!, #new_record?, next_id, #reload, repository, reset, #save, transaction
Constructor Details
#initialize(name:, current: false) ⇒ Mood
Returns a new instance of Mood.
6 7 8 9 |
# File 'lib/moodwall/mood.rb', line 6 def initialize(name:, current: false) @name = name @current = current end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
4 5 6 |
# File 'lib/moodwall/mood.rb', line 4 def current @current end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/moodwall/mood.rb', line 3 def name @name end |
Class Method Details
.choose_current(name:) ⇒ Object
16 17 18 19 |
# File 'lib/moodwall/mood.rb', line 16 def choose_current(name:) nullify_current choose_new_current(name) end |
.current ⇒ Object
12 13 14 |
# File 'lib/moodwall/mood.rb', line 12 def current all.find { |m| m.current == true } end |
.find_by_name(name) ⇒ Object
21 22 23 |
# File 'lib/moodwall/mood.rb', line 21 def find_by_name(name) all.find { |m| m.name.casecmp(name).zero? } end |
.list_names ⇒ Object
25 26 27 |
# File 'lib/moodwall/mood.rb', line 25 def list_names all.map(&:name) end |