geocaching 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/README.markdown +6 -0
  2. data/geocaching.gemspec +3 -1
  3. data/lib/geocaching.rb +4 -1
  4. data/lib/geocaching/cache.rb +65 -21
  5. data/lib/geocaching/cache_type.rb +57 -13
  6. data/lib/geocaching/log.rb +34 -2
  7. data/lib/geocaching/log_type.rb +57 -19
  8. data/lib/geocaching/my_logs.rb +150 -0
  9. data/lib/geocaching/user.rb +251 -0
  10. data/lib/geocaching/version.rb +3 -0
  11. data/spec/cache/ape.rb +69 -0
  12. data/spec/cache/cito.rb +12 -0
  13. data/spec/cache/earthcache.rb +12 -0
  14. data/spec/cache/event.rb +12 -0
  15. data/spec/cache/letterbox.rb +12 -0
  16. data/spec/cache/lfevent.rb +12 -0
  17. data/spec/cache/locationless.rb +12 -0
  18. data/spec/cache/megaevent.rb +12 -0
  19. data/spec/cache/multi.rb +27 -15
  20. data/spec/cache/mystery.rb +12 -0
  21. data/spec/cache/traditional.rb +12 -0
  22. data/spec/cache/virtual.rb +12 -0
  23. data/spec/cache/webcam.rb +12 -0
  24. data/spec/cache/wherigo.rb +12 -0
  25. data/spec/cache_spec.rb +3 -2
  26. data/spec/log/announcement.rb +28 -0
  27. data/spec/log/announcement.txt +14 -0
  28. data/spec/log/archive.rb +28 -0
  29. data/spec/log/archive.txt +5 -0
  30. data/spec/log/attended.rb +28 -0
  31. data/spec/log/attended.txt +1 -0
  32. data/spec/log/coords_update.rb +28 -0
  33. data/spec/log/coords_update.txt +9 -0
  34. data/spec/log/disable.rb +28 -0
  35. data/spec/log/disable.txt +3 -0
  36. data/spec/log/dnf.rb +28 -0
  37. data/spec/log/dnf.txt +5 -0
  38. data/spec/log/enable.rb +28 -0
  39. data/spec/log/enable.txt +1 -0
  40. data/spec/log/found.rb +28 -0
  41. data/spec/{log_message.txt → log/found.txt} +0 -0
  42. data/spec/log/needs_archived.rb +28 -0
  43. data/spec/log/needs_archived.txt +1 -0
  44. data/spec/log/needs_maintenance.rb +28 -0
  45. data/spec/log/needs_maintenance.txt +1 -0
  46. data/spec/log/note.rb +28 -0
  47. data/spec/log/note.txt +1 -0
  48. data/spec/log/owner_maintenance.rb +28 -0
  49. data/spec/log/owner_maintenance.txt +1 -0
  50. data/spec/log/publish.rb +28 -0
  51. data/spec/log/publish.txt +1 -0
  52. data/spec/log/retract.rb +28 -0
  53. data/spec/log/retract.txt +4 -0
  54. data/spec/log/reviewer_note.rb +28 -0
  55. data/spec/log/reviewer_note.txt +3 -0
  56. data/spec/log/unarchive.rb +28 -0
  57. data/spec/log/unarchive.txt +1 -0
  58. data/spec/log/webcam_photo_taken.rb +28 -0
  59. data/spec/log/webcam_photo_taken.txt +1 -0
  60. data/spec/log/will_attend.rb +28 -0
  61. data/spec/log/will_attend.txt +1 -0
  62. data/spec/log_spec.rb +7 -17
  63. data/spec/user_spec.rb +48 -0
  64. metadata +44 -6
  65. data/lib/geocaching/mylogs.rb +0 -63
@@ -5,6 +5,12 @@ This Ruby library provides an API for geocaching.com. As Groundspeak
5
5
  doesn’t offer an official API yet, this library parses the website’s
6
6
  HTML code.
7
7
 
8
+ Documentation
9
+ -------------
10
+
11
+ Documentation is available at
12
+ [rdoc.info](http://rdoc.info/projects/nano/ruby-geocaching).
13
+
8
14
  Example
9
15
  -------
10
16
 
@@ -1,6 +1,8 @@
1
+ require "#{File.dirname(__FILE__)}/lib/geocaching/version"
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = "geocaching"
3
- s.version = "0.3.0"
5
+ s.version = Geocaching::VERSION
4
6
 
5
7
  s.summary = "Ruby API for geocaching.com"
6
8
  s.description = "A Ruby library that provides an API for geocaching.com"
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require "nokogiri"
4
+ require "geocaching/version"
4
5
 
5
6
  # This is a Ruby library to access information on geocaching.com. As
6
7
  # Groundspeak does not provide a public API yet, one needs to parse the
@@ -71,5 +72,7 @@ module Geocaching
71
72
  autoload :Cache, "geocaching/cache"
72
73
  autoload :CacheType, "geocaching/cache_type"
73
74
  autoload :Log, "geocaching/log"
74
- autoload :MyLogs, "geocaching/mylogs"
75
+ autoload :LogType, "geocaching/log_type"
76
+ autoload :MyLogs, "geocaching/my_logs"
77
+ autoload :User, "geocaching/user"
75
78
  end
@@ -29,7 +29,7 @@ module Geocaching
29
29
  # puts cache.archived? #=> false
30
30
  #
31
31
  class Cache
32
- # Creates a new instance and calls the {#fetch} methods afterwards.
32
+ # Create a new instance and call the {#fetch} methods afterwards.
33
33
  # One of +:code+ or +:guid+ must be provided as attributes.
34
34
  #
35
35
  # @param [Hash] attributes A hash of attributes, see {#initialize}
@@ -42,7 +42,7 @@ module Geocaching
42
42
  cache
43
43
  end
44
44
 
45
- # Creates a new instance. The following attributes may be specified
45
+ # Create a new instance. The following attributes may be specified
46
46
  # as parameters:
47
47
  #
48
48
  # * +:code+ — The cache’s GC code
@@ -54,7 +54,11 @@ module Geocaching
54
54
  @data, @doc, @code, @guid = nil, nil, nil, nil
55
55
 
56
56
  attributes.each do |key, value|
57
- if [:code, :guid].include?(key)
57
+ if [:code, :guid, :name, :type].include?(key)
58
+ if key == :type and not value.kind_of?(CacheType)
59
+ raise TypeError, "Attribute `type' must be an instance of Geocaching::CacheType"
60
+ end
61
+
58
62
  instance_variable_set("@#{key}", value)
59
63
  else
60
64
  raise ArgumentError, "Trying to set unknown attribute `#{key}'"
@@ -62,7 +66,7 @@ module Geocaching
62
66
  end
63
67
  end
64
68
 
65
- # Fetches cache information from geocaching.com.
69
+ # Fetche cache information from geocaching.com.
66
70
  #
67
71
  # @return [void]
68
72
  # @raise [ArgumentError] Neither code nor GUID are given
@@ -75,7 +79,7 @@ module Geocaching
75
79
  @doc = Nokogiri::HTML.parse(@data)
76
80
  end
77
81
 
78
- # Whether information have successfully been fetched
82
+ # Return whether information have successfully been fetched
79
83
  # from geocaching.com.
80
84
  #
81
85
  # @return [Boolean] Have information been fetched?
@@ -83,7 +87,7 @@ module Geocaching
83
87
  @data and @doc
84
88
  end
85
89
 
86
- # The cache’s code (GCXXXXXX).
90
+ # Return the cache’s code (GCXXXXXX).
87
91
  #
88
92
  # @return [String] Code
89
93
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -101,7 +105,7 @@ module Geocaching
101
105
  end
102
106
  end
103
107
 
104
- # The cache’s Globally Unique Identifier.
108
+ # Return the cache’s Globally Unique Identifier (GUID).
105
109
  #
106
110
  # @return [String] GUID
107
111
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -123,7 +127,7 @@ module Geocaching
123
127
  end
124
128
  end
125
129
 
126
- # The cache’s type ID.
130
+ # Return the cache’s type ID.
127
131
  #
128
132
  # @return [Fixnum] Type ID
129
133
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -140,7 +144,7 @@ module Geocaching
140
144
  end
141
145
  end
142
146
 
143
- # The cache’s type.
147
+ # Return the cache’s type.
144
148
  #
145
149
  # @return [Geocaching::CacheType] Type
146
150
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -149,7 +153,7 @@ module Geocaching
149
153
  @type ||= CacheType.for_id(type_id)
150
154
  end
151
155
 
152
- # The cache’s name.
156
+ # Return the cache’s name.
153
157
  #
154
158
  # @return [String] Name
155
159
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -167,7 +171,35 @@ module Geocaching
167
171
  end
168
172
  end
169
173
 
170
- # The cache’s difficulty rating.
174
+ # Return the cache’s owner.
175
+ #
176
+ # @return [Geocaching::User]
177
+ # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
178
+ # @raise [Geocaching::ExtractError] Could not extract info from website"
179
+ def owner
180
+ @owner ||= begin
181
+ raise NotFetchedError unless fetched?
182
+
183
+ if @data =~ /<strong>\s*?A[(n\s*?Event)]*\s*?cache\s*?<\/strong>\s*?by\s*?<a.*?guid=([a-f0-9-]{36}).*?>(.*?)<\/a>/
184
+ @owner_display_name = HTTP.unescape($2)
185
+ User.new(:guid => $1)
186
+ else
187
+ raise ExtractError, "Could not extract owner from website"
188
+ end
189
+ end
190
+ end
191
+
192
+ # Return the displayed cache owner name.
193
+ #
194
+ # @return [String]
195
+ # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
196
+ # @raise [Geocaching::ExtractError] Could not extract info from website"
197
+ def owner_display_name
198
+ owner unless @owner_display_name
199
+ @owner_display_name
200
+ end
201
+
202
+ # Return the cache’s difficulty rating.
171
203
  #
172
204
  # @return [Float] Difficulty rating
173
205
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -184,7 +216,7 @@ module Geocaching
184
216
  end
185
217
  end
186
218
 
187
- # The cache’s terrain rating.
219
+ # Return the cache’s terrain rating.
188
220
  #
189
221
  # @return [Float] Terrain rating
190
222
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -201,7 +233,7 @@ module Geocaching
201
233
  end
202
234
  end
203
235
 
204
- # The date the cache has been hidden at.
236
+ # Return the date the cache has been hidden at.
205
237
  #
206
238
  # @return [Time] Hidden date
207
239
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -218,7 +250,7 @@ module Geocaching
218
250
  end
219
251
  end
220
252
 
221
- # The date the event has been held.
253
+ # Return the date the event has been held.
222
254
  #
223
255
  # @return [Time] Event date
224
256
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -236,7 +268,7 @@ module Geocaching
236
268
  end
237
269
  end
238
270
 
239
- # The cache’s container size.
271
+ # Return the cache’s container size.
240
272
  #
241
273
  # @return [Symbol] Cache container size
242
274
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -256,7 +288,7 @@ module Geocaching
256
288
  end
257
289
  end
258
290
 
259
- # The cache’s latitude.
291
+ # Return the cache’s latitude.
260
292
  #
261
293
  # @return [Float] Latitude
262
294
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -279,7 +311,7 @@ module Geocaching
279
311
  end
280
312
  end
281
313
 
282
- # The cache’s longitude.
314
+ # Return the cache’s longitude.
283
315
  #
284
316
  # @return [Float] Longitude
285
317
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -302,7 +334,7 @@ module Geocaching
302
334
  end
303
335
  end
304
336
 
305
- # The cache’s location name (State, Country).
337
+ # Return the cache’s location name (State, Country).
306
338
  #
307
339
  # @return [String] Location name
308
340
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -326,7 +358,7 @@ module Geocaching
326
358
  end
327
359
  end
328
360
 
329
- # Whether the cache has been archived or not.
361
+ # Return whether the cache has been archived or not.
330
362
  #
331
363
  # @return [Boolean] Has cache been archived?
332
364
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -337,7 +369,7 @@ module Geocaching
337
369
  end
338
370
  end
339
371
 
340
- # Whether the cache is only viewable to Premium Member only.
372
+ # Return whether the cache is only viewable to Premium Member only.
341
373
  #
342
374
  # @return [Boolean] Is cache PM-only?
343
375
  # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
@@ -350,7 +382,19 @@ module Geocaching
350
382
  end
351
383
  end
352
384
 
353
- # Returns an array of logs for this cache. A log is an instance of
385
+ # Return whether the cache is currently in review.
386
+ #
387
+ # @return [Boolean] Is cache currently in review?
388
+ # @raise [Geocaching::NotFetchedError] Need to call {#fetch} first
389
+ def in_review?
390
+ @in_review ||= begin
391
+ raise NotFetchedError unless fetched?
392
+ [!!@data.match(/<p class="Warning">Sorry, you cannot view this cache listing until it has been published/),
393
+ !!@data.match(/<p class="Warning">This cache listing has not been reviewed yet/)].any?
394
+ end
395
+ end
396
+
397
+ # Return an array of logs for this cache. A log is an instance of
354
398
  # {Geocaching::Log}.
355
399
  #
356
400
  # @return [Geocaching::LogsArray<Geocaching::Log>] Array of logs
@@ -1,44 +1,88 @@
1
1
  module Geocaching
2
+ # This class represents a cache type.
3
+ #
4
+ # if @cache.type == :traditional
5
+ # puts "Cache is a Traditional Cache"
6
+ # end
2
7
  class CacheType
8
+ # A mapping of cache types to their corresponding ID and name
9
+ # on geocaching.com.
3
10
  TYPES = {
4
- :traditional => [2, "Traditional Cache"],
5
- :multi => [3, "Multi Cache"],
6
- :mystery => [8, "Mystery Cache"],
7
- :letterbox => [5, "Letterbox Hybrid"],
8
- :wherigo => [1858, "Wherigo"],
9
- :event => [6, "Event Cache"],
10
- :megaevent => [453, "Mega Event Cache"],
11
- :cito => [13, "Cache In Trash Out Event"],
12
- :earthcache => [137, "EarthCache"],
11
+ :traditional => [2, "Traditional Cache"],
12
+ :multi => [3, "Multi-cache"],
13
+ :mystery => [8, "Unknown Cache"],
14
+ :letterbox => [5, "Letterbox Hybrid"],
15
+ :wherigo => [1858, "Wherigo Cache"],
16
+ :event => [6, "Event Cache"],
17
+ :megaevent => [453, "Mega-Event Cache"],
18
+ :cito => [13, "Cache In Trash Out Event"],
19
+ :earthcache => [137, "Earthcache"],
13
20
  :lfevent => [3653, "Lost and Found Event Cache"],
14
- :locationless => [12, "Locationless Reverse Cache"],
15
- :webcam => [11, "Webcam Cache"],
16
- :virtual => [4, "Virtual Cache"],
17
- :ape => [32, "Project A.P.E. Cache"] # XXX
21
+ :locationless => [12, "Locationless (Reverse) Cache"],
22
+ :webcam => [11, "Webcam Cache"],
23
+ :virtual => [4, "Virtual Cache"],
24
+ :ape => [9, "Project APE Cache"]
18
25
  }
19
26
 
27
+ # Return a {CacheType} object for the given cache type id, or
28
+ # nil if no appropriate cache id is found.
29
+ #
30
+ # @return [Geocaching::CacheType]
31
+ # @return [nil] If no appropriate cache type is found
20
32
  def self.for_id(id)
21
33
  if info = TYPES.to_a.select { |(k,v)| v[0] == id } and info.size == 1
22
34
  new(info.first)
23
35
  end
24
36
  end
25
37
 
38
+ # Return a {CacheType} object for the given cache type title, or
39
+ # nil if no appropriate cache type is found.
40
+ #
41
+ # @return [Geocaching::CacheType]
42
+ # @return [nil] If no appropriate cache type is found
43
+ def self.for_title(title)
44
+ if info = TYPES.to_a.select { |(k,v)| v[1] == title } and info.size == 1
45
+ new(info.first)
46
+ end
47
+ end
48
+
49
+ # Create a new instance. You should not need to create an instance
50
+ # of this class on your own. Use {for_id} and {for_title}.
26
51
  def initialize(info)
27
52
  @info = info
28
53
  end
29
54
 
55
+ # Return the cache type’s ID.
56
+ #
57
+ # @return [Fixnum]
30
58
  def id
31
59
  @info[1][0]
32
60
  end
33
61
 
62
+ # Return the cache type’s name.
63
+ #
64
+ # @return [String]
34
65
  def name
35
66
  @info[1][1]
36
67
  end
37
68
 
69
+ alias to_s name
70
+
71
+ # Return the symbol that describes this cache type. See the {TYPES}
72
+ # hash for a list of cache type symbols.
73
+ #
74
+ # @return [Symbol]
38
75
  def to_sym
39
76
  @info[0]
40
77
  end
41
78
 
79
+ # Overload the == operator.
80
+ #
81
+ # if @cache.type == :multi
82
+ # puts "It's a multi cache."
83
+ # end
84
+ #
85
+ # @return [Boolean]
42
86
  def ==(s)
43
87
  to_sym == s
44
88
  end
@@ -30,11 +30,15 @@ module Geocaching
30
30
  @data, @doc, @guid, @cache = nil, nil, nil, nil
31
31
 
32
32
  attributes.each do |key, value|
33
- if [:guid, :title, :cache].include?(key)
33
+ if [:guid, :title, :date, :cache].include?(key)
34
34
  if key == :cache and not value.kind_of?(Geocaching::Cache)
35
35
  raise TypeError, "Attribute `cache' must be an instance of Geocaching::Cache"
36
36
  end
37
37
 
38
+ if key == :date and not value.kind_of?(Time)
39
+ raise TypeError, "Attribute `type' must be an instance of Time"
40
+ end
41
+
38
42
  instance_variable_set("@#{key}", value)
39
43
  else
40
44
  raise ArgumentError, "Trying to set unknown attribute `#{key}'"
@@ -76,8 +80,22 @@ module Geocaching
76
80
  end
77
81
  end
78
82
 
83
+ def type
84
+ @type ||= LogType.for_title(title)
85
+ end
86
+
79
87
  def title
80
- @title
88
+ @title ||= begin
89
+ raise NotFetchedError unless fetched?
90
+
91
+ imgs = @doc.search("#ctl00_ContentBody_LogBookPanel1_LogImage")
92
+
93
+ unless imgs.size == 1 and imgs.first["alt"]
94
+ raise ExtractError, "Could not extract title from website"
95
+ end
96
+
97
+ imgs.first["alt"]
98
+ end
81
99
  end
82
100
 
83
101
  # The name of the user that has posted this log.
@@ -99,6 +117,20 @@ module Geocaching
99
117
  end
100
118
  end
101
119
 
120
+ def date
121
+ @date ||= begin
122
+ raise NotFetchedError unless fetched?
123
+
124
+ elements = @doc.search("#ctl00_ContentBody_LogBookPanel1_LogDate")
125
+
126
+ if elements.size == 1
127
+ Time.parse(elements.first.content)
128
+ else
129
+ raise ExtractError, "Could not extract date from website"
130
+ end
131
+ end
132
+ end
133
+
102
134
  # The log’s raw message with all format codes.
103
135
  #
104
136
  # @return [String] Log message
@@ -1,54 +1,92 @@
1
1
  module Geocaching
2
+ # This class represents a log type.
3
+ #
4
+ # if @log.type == :archive
5
+ # puts "#{@log.cache.code} has been archived"
6
+ # end
2
7
  class LogType
8
+ # Mapping of log types to their corresponding icon and title
9
+ # on geocaching.com.
3
10
  TYPES = {
4
- :published => ["icon_greenlight", "Publish Listing"],
5
- :retracted => ["", ""], # TODO
6
- :dnf => ["icon_sad", "Didn't find it"],
7
- :found => ["icon_smile", "Found it"],
8
- :webcam_photo_taken => ["", ""], # TODO
9
- :will_attend => ["icon_rsvp", "Will Attend"],
10
- :announcement => ["icon_announcement", "Announcement"],
11
- :attended => ["icon_attended", "Attended"],
12
- :needs_maintenance => ["icon_needsmaint", "Needs Maintenance"],
13
- :owner_maintenance => ["icon_maint", "Owner Maintenance"],
14
- :disabled => ["icon_disabled", "Temporarily Disable Listing"],
15
- :enabled => ["icon_enabled", "Enable Listing"],
16
- :note => ["icon_note", "Write Note"],
17
- :needs_archived => ["icon_remove", "Needs Archived"],
18
- :archived => ["traffic_cone", "Archive"],
19
- :unarchived => ["traffic_cone", "Unarchive"],
20
- :coords_updated => ["coord_update", "Update Coordinates"],
21
- :reviewer_note => ["big_smile", "Post Reviewer Note"]
11
+ :publish => ["icon_greenlight", "Publish Listing"],
12
+ :retract => ["icon_redlight", "Retract Listing"],
13
+ :dnf => ["icon_sad", "Didn't find it"],
14
+ :found => ["icon_smile", "Found it"],
15
+ :webcam_photo_taken => ["icon_camera", "Webcam Photo Taken"],
16
+ :will_attend => ["icon_rsvp", "Will Attend"],
17
+ :announcement => ["icon_announcement", "Announcement"],
18
+ :attended => ["icon_attended", "Attended"],
19
+ :needs_maintenance => ["icon_needsmaint", "Needs Maintenance"],
20
+ :owner_maintenance => ["icon_maint", "Owner Maintenance"],
21
+ :disable => ["icon_disabled", "Temporarily Disable Listing"],
22
+ :enable => ["icon_enabled", "Enable Listing"],
23
+ :note => ["icon_note", "Write note"],
24
+ :needs_archived => ["icon_remove", "Needs Archived"],
25
+ :archive => ["traffic_cone", "Archive"],
26
+ :unarchive => ["traffic_cone", "Unarchive"],
27
+ :coords_update => ["coord_update", "Update Coordinates"],
28
+ :reviewer_note => ["big_smile", "Post Reviewer Note"]
22
29
  }
23
30
 
31
+ # Return a {LogType} object for the given log type icon, or nil if
32
+ # no appropriate log type is found.
33
+ #
34
+ # @return [Geocaching::LogType]
35
+ # @return [nil] If no appropriate log type is found
24
36
  def self.for_icon(icon)
25
37
  if info = TYPES.to_a.select { |(k,v)| v[0] == icon } and info.size == 1
26
38
  new(info.first)
27
39
  end
28
40
  end
29
41
 
42
+ # Return a {LogType} object for the given log type title, or nil if
43
+ # no appropriate log type is found.
44
+ #
45
+ # @return [Geocaching::LogType]
46
+ # @return [nil] If no appropriate log type is found
30
47
  def self.for_title(title)
31
48
  if info = TYPES.to_a.select { |(k,v)| v[1] == title } and info.size == 1
32
49
  new(info.first)
33
50
  end
34
51
  end
35
52
 
36
- def new(info)
53
+ # Create a new instance. You should not need to create an instance
54
+ # of this class on your own. Use {for_icon} and {for_title}.
55
+ def initialize(info)
37
56
  @info = info
38
57
  end
39
58
 
59
+ # Return the log type’s icon.
60
+ #
61
+ # @return [String]
40
62
  def icon
41
63
  @info[1][0]
42
64
  end
43
65
 
66
+ # Return the log type’s title.
67
+ #
68
+ # @return [String]
44
69
  def description
45
70
  @info[1][1]
46
71
  end
47
72
 
73
+ alias to_s description
74
+
75
+ # Return the symbol representatin of the log type. See the {TYPES}
76
+ # hash for a list of log type symbols.
77
+ #
78
+ # @return [Symbol]
48
79
  def to_sym
49
80
  @info[0]
50
81
  end
51
82
 
83
+ # Overload the == operator.
84
+ #
85
+ # if @log.type == :dnf
86
+ # puts "Someone could not find the cache"
87
+ # end
88
+ #
89
+ # @return [Boolean]
52
90
  def ==(s)
53
91
  to_sym == s
54
92
  end