Class: HikingProjectCli::Trail

Inherits:
Object
  • Object
show all
Defined in:
lib/hiking_project_cli/trail.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#ascentObject

Returns the value of attribute ascent.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def ascent
  @ascent
end

#conditionDateObject

Returns the value of attribute conditionDate.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def conditionDate
  @conditionDate
end

#conditionDetailsObject

Returns the value of attribute conditionDetails.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def conditionDetails
  @conditionDetails
end

#conditionStatusObject

Returns the value of attribute conditionStatus.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def conditionStatus
  @conditionStatus
end

#descentObject

Returns the value of attribute descent.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def descent
  @descent
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def description
  @description
end

#difficultyObject

Returns the value of attribute difficulty.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def difficulty
  @difficulty
end

#featuresObject

Returns the value of attribute features.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def features
  @features
end

#highObject

Returns the value of attribute high.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def high
  @high
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def length
  @length
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def location
  @location
end

#lowObject

Returns the value of attribute low.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def low
  @low
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def name
  @name
end

#overviewObject

Returns the value of attribute overview.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def overview
  @overview
end

#starsObject

Returns the value of attribute stars.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def stars
  @stars
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/hiking_project_cli/trail.rb', line 3

def summary
  @summary
end

#urlObject

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

.allObject



23
24
25
# File 'lib/hiking_project_cli/trail.rb', line 23

def self.all
  @@all
end

.clearObject



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


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


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