Class: HikingProjectCli::Trail
- Inherits:
-
Object
- Object
- HikingProjectCli::Trail
- Defined in:
- lib/hiking_project_cli/trail.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#ascent ⇒ Object
Returns the value of attribute ascent.
-
#conditionDate ⇒ Object
Returns the value of attribute conditionDate.
-
#conditionDetails ⇒ Object
Returns the value of attribute conditionDetails.
-
#conditionStatus ⇒ Object
Returns the value of attribute conditionStatus.
-
#descent ⇒ Object
Returns the value of attribute descent.
-
#description ⇒ Object
Returns the value of attribute description.
-
#difficulty ⇒ Object
Returns the value of attribute difficulty.
-
#features ⇒ Object
Returns the value of attribute features.
-
#high ⇒ Object
Returns the value of attribute high.
-
#length ⇒ Object
Returns the value of attribute length.
-
#location ⇒ Object
Returns the value of attribute location.
-
#low ⇒ Object
Returns the value of attribute low.
-
#name ⇒ Object
Returns the value of attribute name.
-
#overview ⇒ Object
Returns the value of attribute overview.
-
#stars ⇒ Object
Returns the value of attribute stars.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_full_details(details_hash) ⇒ Object
-
#initialize(trail_hash) ⇒ Trail
constructor
A new instance of Trail.
- #print_full_description ⇒ Object
- #print_summary ⇒ Object
Constructor Details
#initialize(trail_hash) ⇒ Trail
Returns a new instance of Trail.
7 8 9 10 |
# File 'lib/hiking_project_cli/trail.rb', line 7 def initialize(trail_hash) trail_hash.each {|key, value| self.send(("#{key}="), value)} @@all << self end |
Instance Attribute Details
#ascent ⇒ Object
Returns the value of attribute ascent.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def ascent @ascent end |
#conditionDate ⇒ Object
Returns the value of attribute conditionDate.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def conditionDate @conditionDate end |
#conditionDetails ⇒ Object
Returns the value of attribute conditionDetails.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def conditionDetails @conditionDetails end |
#conditionStatus ⇒ Object
Returns the value of attribute conditionStatus.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def conditionStatus @conditionStatus end |
#descent ⇒ Object
Returns the value of attribute descent.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def descent @descent end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def description @description end |
#difficulty ⇒ Object
Returns the value of attribute difficulty.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def difficulty @difficulty end |
#features ⇒ Object
Returns the value of attribute features.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def features @features end |
#high ⇒ Object
Returns the value of attribute high.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def high @high end |
#length ⇒ Object
Returns the value of attribute length.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def length @length end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def location @location end |
#low ⇒ Object
Returns the value of attribute low.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def low @low end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def name @name end |
#overview ⇒ Object
Returns the value of attribute overview.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def overview @overview end |
#stars ⇒ Object
Returns the value of attribute stars.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def stars @stars end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def summary @summary end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/hiking_project_cli/trail.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
23 24 25 |
# File 'lib/hiking_project_cli/trail.rb', line 23 def self.all @@all end |
.clear ⇒ Object
27 28 29 |
# File 'lib/hiking_project_cli/trail.rb', line 27 def self.clear @@all = Array.new end |
.create_from_collection(trails_array) ⇒ Object
12 13 14 15 16 |
# File 'lib/hiking_project_cli/trail.rb', line 12 def self.create_from_collection(trails_array) trails_array.each {|trail| HikingProjectCli::Trail.new(trail) } end |
Instance Method Details
#add_full_details(details_hash) ⇒ Object
18 19 20 21 |
# File 'lib/hiking_project_cli/trail.rb', line 18 def add_full_details(details_hash) details_hash.each {|key, value| self.send(("#{key}="), value)} self end |
#print_full_description ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hiking_project_cli/trail.rb', line 39 def print_full_description puts "-----------------------------------------------" puts "#{self.name} (#{self.length} miles)" puts "" puts "Location: #{self.location}" unless self.location == nil puts "Summary: #{self.summary}" unless (self.summary == nil || self.summary == "Needs Summary" || self.summary == "") puts "Difficulty: #{self.difficulty}" unless self.difficulty == nil puts "Stars: #{self.stars}" unless self.stars == nil puts "Ascent: #{self.ascent}" unless self.ascent == nil puts "Descent: #{self.descent}" unless self.descent == nil puts "High: #{self.high}" unless self.high == nil puts "Low: #{self.low}" unless self.low == nil puts "Condition Status: #{self.conditionStatus}" unless (self.conditionStatus == nil || self.conditionStatus == "Unknown") puts "Condition Details: #{self.conditionDetails}" unless self.conditionDetails == nil puts "Condition Date: #{self.conditionDate}" unless (self.conditionDate == nil || self.conditionDate == "1970-01-01 00:00:00") puts "" unless (self.features == nil || self.features == "-none-") puts "Features:" unless (self.features == nil || self.features == "-none-") puts "#{self.features}" unless (self.features == nil || self.features == "-none-") puts "" unless self.overview == nil puts "Overview:" unless self.overview == nil puts "#{self.overview}" unless self.overview == nil puts "" unless self.description == nil puts "Description:" unless self.description == nil puts "#{self.description}" unless self.description == nil puts "" puts "-----------------------------------------------" end |
#print_summary ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/hiking_project_cli/trail.rb', line 31 def print_summary if (self.summary != nil && self.summary != "Needs Summary" && self.summary != "") "#{self.name} (#{self.length.to_s} miles) - #{self.summary}" else "#{self.name} (#{self.length.to_s} miles)" end end |