Class: TrailInfo::Trail

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, trail_attributes) ⇒ Trail

Creates new trail instance



7
8
9
10
11
12
# File 'lib/trail_info/trail.rb', line 7

def initialize(state, trail_attributes) #Creates new trail instance
  trail_attributes.each do |attribute_name, attribute_value|
    self.send("#{attribute_name}=", attribute_value)
  end
  save
end

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



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

def length
  @length
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#surfaceObject

Returns the value of attribute surface.



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

def surface
  @surface
end

#synopsisObject

Returns the value of attribute synopsis.



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

def synopsis
  @synopsis
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.allObject

returns all trail instances



18
19
20
# File 'lib/trail_info/trail.rb', line 18

def self.all #returns all trail instances
  @@all
end

Instance Method Details

#saveObject

saves trail instance



14
15
16
# File 'lib/trail_info/trail.rb', line 14

def save #saves trail instance
  @@all << self
end