Class: HikingGuide::Trail
- Inherits:
-
Object
- Object
- HikingGuide::Trail
- Defined in:
- lib/hiking_guide/trail.rb
Constant Summary collapse
- @@all =
[]
- @@md =
[]
- @@pa =
[]
- @@nc =
[]
- @@va =
[]
- @@wv =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#elevation_gain ⇒ Object
Returns the value of attribute elevation_gain.
-
#hiking_time ⇒ Object
Returns the value of attribute hiking_time.
-
#length ⇒ Object
Returns the value of attribute length.
-
#map_pdf_link ⇒ Object
Returns the value of attribute map_pdf_link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#profile_url ⇒ Object
Returns the value of attribute profile_url.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_collection(trails_array) ⇒ Object
- .md ⇒ Object
- .nc ⇒ Object
- .pa ⇒ Object
- .reset_all ⇒ Object
- .update_state_lists ⇒ Object
- .va ⇒ Object
- .wv ⇒ Object
Instance Method Summary collapse
- #add_trail_attributes(attributes_hash) ⇒ Object
-
#initialize(trail_hash) ⇒ Trail
constructor
A new instance of Trail.
Constructor Details
#initialize(trail_hash) ⇒ Trail
Returns a new instance of Trail.
10 11 12 13 14 |
# File 'lib/hiking_guide/trail.rb', line 10 def initialize(trail_hash) trail_hash.each {|key, value| self.send("#{key}=", "#{value}")} HikingGuide::Trail.all << self HikingGuide::Trail.update_state_lists end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def description @description end |
#elevation_gain ⇒ Object
Returns the value of attribute elevation_gain.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def elevation_gain @elevation_gain end |
#hiking_time ⇒ Object
Returns the value of attribute hiking_time.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def hiking_time @hiking_time end |
#length ⇒ Object
Returns the value of attribute length.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def length @length end |
#map_pdf_link ⇒ Object
Returns the value of attribute map_pdf_link.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def map_pdf_link @map_pdf_link end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def name @name end |
#profile_url ⇒ Object
Returns the value of attribute profile_url.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def profile_url @profile_url end |
#state ⇒ Object
Returns the value of attribute state.
2 3 4 |
# File 'lib/hiking_guide/trail.rb', line 2 def state @state end |
Class Method Details
.all ⇒ Object
45 46 47 |
# File 'lib/hiking_guide/trail.rb', line 45 def self.all @@all end |
.create_from_collection(trails_array) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/hiking_guide/trail.rb', line 16 def self.create_from_collection(trails_array) trails_array.each do |trail| if HikingGuide::Trail.all.include?(trail) == false HikingGuide::Trail.new(trail) end end end |
.md ⇒ Object
49 50 51 |
# File 'lib/hiking_guide/trail.rb', line 49 def self.md @@md end |
.nc ⇒ Object
57 58 59 |
# File 'lib/hiking_guide/trail.rb', line 57 def self.nc @@nc end |
.pa ⇒ Object
53 54 55 |
# File 'lib/hiking_guide/trail.rb', line 53 def self.pa @@pa end |
.reset_all ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/hiking_guide/trail.rb', line 69 def self.reset_all @@all.clear @@md.clear @@pa.clear @@nc.clear @@va.clear @@wv.clear end |
.update_state_lists ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hiking_guide/trail.rb', line 28 def self.update_state_lists self.all.each do |trail| case trail.state when "MD" self.md.include?(trail) ? nil : self.md << trail when "PA" self.pa.include?(trail) ? nil : self.pa << trail when "NC" self.nc.include?(trail) ? nil : self.nc << trail when "VA" self.va.include?(trail) ? nil : self.va << trail when "WV" self.wv.include?(trail) ? nil : self.wv << trail end end end |
.va ⇒ Object
61 62 63 |
# File 'lib/hiking_guide/trail.rb', line 61 def self.va @@va end |
.wv ⇒ Object
65 66 67 |
# File 'lib/hiking_guide/trail.rb', line 65 def self.wv @@wv end |
Instance Method Details
#add_trail_attributes(attributes_hash) ⇒ Object
24 25 26 |
# File 'lib/hiking_guide/trail.rb', line 24 def add_trail_attributes(attributes_hash) attributes_hash.each {|key, value| self.send("#{key}=", "#{value}")} end |