Class: Rubedility::Task
- Inherits:
-
Object
- Object
- Rubedility::Task
- Defined in:
- lib/rubedility/task.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#difficulty ⇒ Object
Returns the value of attribute difficulty.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tagline ⇒ Object
Returns the value of attribute tagline.
-
#task_reading_url ⇒ Object
Returns the value of attribute task_reading_url.
-
#task_url ⇒ Object
Returns the value of attribute task_url.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_collection(task_hash) ⇒ Object
- .display_all ⇒ Object
- .user_display_one ⇒ Object
Instance Method Summary collapse
- #add_task_attributes(attributes_hash) ⇒ Object
- #display_content ⇒ Object
- #display_row ⇒ Object
-
#initialize(task_row) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(task_row) ⇒ Task
Returns a new instance of Task.
4 5 6 7 |
# File 'lib/rubedility/task.rb', line 4 def initialize(task_row) add_task_attributes(task_row) @@all.push(self) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def content @content end |
#difficulty ⇒ Object
Returns the value of attribute difficulty.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def difficulty @difficulty end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def name @name end |
#tagline ⇒ Object
Returns the value of attribute tagline.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def tagline @tagline end |
#task_reading_url ⇒ Object
Returns the value of attribute task_reading_url.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def task_reading_url @task_reading_url end |
#task_url ⇒ Object
Returns the value of attribute task_url.
2 3 4 |
# File 'lib/rubedility/task.rb', line 2 def task_url @task_url end |
Class Method Details
.all ⇒ Object
30 31 32 |
# File 'lib/rubedility/task.rb', line 30 def self.all @@all end |
.create_from_collection(task_hash) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubedility/task.rb', line 11 def self.create_from_collection(task_hash) task_hash.each do |task| Task.new(task) end end |
.display_all ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/rubedility/task.rb', line 60 def self.display_all puts "\nAvailable Tasks: \n" self.all.each do |task| task.display_row end return nil end |
.user_display_one ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubedility/task.rb', line 34 def self.user_display_one print "Enter Task Name:" input = gets.strip.downcase self.all.each do |task| if task.name.downcase==input task.display_content return nil end end self.display_all puts "Try better next time." end |
Instance Method Details
#add_task_attributes(attributes_hash) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubedility/task.rb', line 17 def add_task_attributes(attributes_hash) if attributes_hash == nil return end attributes_hash.each do |key, val| self.send(("#{key}="), val) if key.to_s == "difficulty" d = Difficulty.find_or_create(val) d.add_task(self) end end end |
#display_content ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rubedility/task.rb', line 52 def display_content puts "=========================================" puts "==========#{self.name}==========" puts "=========================================" puts "Difficulty: #{self.difficulty}" puts @content end |
#display_row ⇒ Object
47 48 49 50 |
# File 'lib/rubedility/task.rb', line 47 def display_row puts "=#{self.name}= (#{self.difficulty})" puts "#{self.tagline}\n\n" end |