Class: GCStats::Caches::Cache
- Inherits:
-
Object
- Object
- GCStats::Caches::Cache
- Defined in:
- lib/gcstats/caches.rb
Instance Method Summary collapse
- #archived? ⇒ Boolean
- #available? ⇒ Boolean
- #code ⇒ Object
- #container ⇒ Object (also: #size)
- #country ⇒ Object
- #difficulty ⇒ Object
- #find_dates ⇒ Object
-
#initialize(wpt_node) ⇒ Cache
constructor
A new instance of Cache.
- #lat ⇒ Object (also: #latitude)
- #logs ⇒ Object
- #lon ⇒ Object (also: #longitude)
- #name ⇒ Object
- #owner ⇒ Object
- #placed_by ⇒ Object
- #published ⇒ Object (also: #time)
- #state ⇒ Object
- #terrain ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(wpt_node) ⇒ Cache
Returns a new instance of Cache.
19 20 21 22 |
# File 'lib/gcstats/caches.rb', line 19 def initialize(wpt_node) @wpt_node = wpt_node @cache_node = wpt_node.elements["#{NS}:cache"] end |
Instance Method Details
#archived? ⇒ Boolean
54 55 56 |
# File 'lib/gcstats/caches.rb', line 54 def archived? @archived ||= @cache_node.attributes['archived'].to_s.downcase == 'true' end |
#available? ⇒ Boolean
50 51 52 |
# File 'lib/gcstats/caches.rb', line 50 def available? @available ||= @cache_node.attributes['available'].to_s.downcase == 'true' end |
#code ⇒ Object
42 43 44 |
# File 'lib/gcstats/caches.rb', line 42 def code @code ||= @wpt_node.elements['name'].text end |
#container ⇒ Object Also known as: size
74 75 76 |
# File 'lib/gcstats/caches.rb', line 74 def container @container ||= @cache_node.elements["#{NS}:container"].text end |
#country ⇒ Object
88 89 90 |
# File 'lib/gcstats/caches.rb', line 88 def country @country ||= @cache_node.elements["#{NS}:country"].text end |
#difficulty ⇒ Object
80 81 82 |
# File 'lib/gcstats/caches.rb', line 80 def difficulty @difficulty ||= @cache_node.elements["#{NS}:difficulty"].text.to_f end |
#find_dates ⇒ Object
108 109 110 111 112 |
# File 'lib/gcstats/caches.rb', line 108 def find_dates @find_dates ||= begin logs.select {|log| log.found? }.map {|log| log.date } end end |
#lat ⇒ Object Also known as: latitude
24 25 26 |
# File 'lib/gcstats/caches.rb', line 24 def lat @lat ||= @wpt_node.attributes['lat'].to_f end |
#logs ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gcstats/caches.rb', line 96 def logs @logs ||= begin logs = [] @cache_node.each_element("#{NS}:logs/#{NS}:log") {|log_node| logs << Log.new(log_node) } logs end end |
#lon ⇒ Object Also known as: longitude
30 31 32 |
# File 'lib/gcstats/caches.rb', line 30 def lon @lon ||= @wpt_node.attributes['lon'].to_f end |
#name ⇒ Object
58 59 60 |
# File 'lib/gcstats/caches.rb', line 58 def name @name ||= @cache_node.elements["#{NS}:name"].text end |
#owner ⇒ Object
62 63 64 |
# File 'lib/gcstats/caches.rb', line 62 def owner @owner ||= @cache_node.elements["#{NS}:owner"].text end |
#placed_by ⇒ Object
66 67 68 |
# File 'lib/gcstats/caches.rb', line 66 def placed_by @placed_by ||= @cache_node.elements["#{NS}:placed_by"].text end |
#published ⇒ Object Also known as: time
36 37 38 |
# File 'lib/gcstats/caches.rb', line 36 def published @published ||= Time.parse(@wpt_node.elements['time'].text) end |
#state ⇒ Object
92 93 94 |
# File 'lib/gcstats/caches.rb', line 92 def state @state ||= @cache_node.elements["#{NS}:state"].text.strip end |
#terrain ⇒ Object
84 85 86 |
# File 'lib/gcstats/caches.rb', line 84 def terrain @terrain ||= @cache_node.elements["#{NS}:terrain"].text.to_f end |
#type ⇒ Object
70 71 72 |
# File 'lib/gcstats/caches.rb', line 70 def type @type ||= @cache_node.elements["#{NS}:type"].text end |
#url ⇒ Object
46 47 48 |
# File 'lib/gcstats/caches.rb', line 46 def url @url ||= @wpt_node.elements['url'].text end |