Class: Topic
- Inherits:
-
Object
- Object
- Topic
- Defined in:
- lib/dbc_today/models/topic.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#phase ⇒ Object
readonly
Returns the value of attribute phase.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Topic
constructor
A new instance of Topic.
Constructor Details
#initialize(attributes) ⇒ Topic
Returns a new instance of Topic.
4 5 6 7 8 9 |
# File 'lib/dbc_today/models/topic.rb', line 4 def initialize(attributes) @phase = attributes.fetch(:phase) @week = attributes.fetch(:week) @day = attributes.fetch(:day) @description = attributes.fetch(:description) end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
2 3 4 |
# File 'lib/dbc_today/models/topic.rb', line 2 def day @day end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
2 3 4 |
# File 'lib/dbc_today/models/topic.rb', line 2 def description @description end |
#phase ⇒ Object (readonly)
Returns the value of attribute phase.
2 3 4 |
# File 'lib/dbc_today/models/topic.rb', line 2 def phase @phase end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
2 3 4 |
# File 'lib/dbc_today/models/topic.rb', line 2 def week @week end |
Class Method Details
.all ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dbc_today/models/topic.rb', line 11 def self.all list = [] CSV.foreach( "#{current_directory}/../data/topics.csv", headers: true, header_converters: :symbol, skip_blanks: true ) do |row| list << Topic.new(row) end list end |
.current_directory ⇒ Object
34 35 36 |
# File 'lib/dbc_today/models/topic.rb', line 34 def self.current_directory File. File.dirname(__FILE__) end |
.where(args) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dbc_today/models/topic.rb', line 26 def self.where(args) all.select { |topic| topic.phase == args[:phase] && topic.week == args[:week] && topic.day == args[:day] } end |