rcap 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/{CHANGELOG.rdoc → CHANGELOG.md} +26 -20
  2. data/README.md +259 -0
  3. data/Rakefile +8 -7
  4. data/lib/extensions/array.rb +7 -1
  5. data/lib/extensions/date_time.rb +5 -1
  6. data/lib/extensions/string.rb +14 -1
  7. data/lib/extensions/time.rb +5 -1
  8. data/lib/rcap.rb +1 -1
  9. data/lib/rcap/alert.rb +24 -10
  10. data/lib/rcap/cap_1_0/alert.rb +232 -166
  11. data/lib/rcap/cap_1_0/area.rb +100 -67
  12. data/lib/rcap/cap_1_0/circle.rb +47 -22
  13. data/lib/rcap/cap_1_0/event_code.rb +3 -2
  14. data/lib/rcap/cap_1_0/geocode.rb +3 -2
  15. data/lib/rcap/cap_1_0/info.rb +265 -202
  16. data/lib/rcap/cap_1_0/parameter.rb +43 -20
  17. data/lib/rcap/cap_1_0/point.rb +23 -9
  18. data/lib/rcap/cap_1_0/polygon.rb +37 -19
  19. data/lib/rcap/cap_1_0/resource.rb +77 -55
  20. data/lib/rcap/cap_1_1/alert.rb +222 -156
  21. data/lib/rcap/cap_1_1/area.rb +100 -67
  22. data/lib/rcap/cap_1_1/circle.rb +49 -22
  23. data/lib/rcap/cap_1_1/event_code.rb +3 -2
  24. data/lib/rcap/cap_1_1/geocode.rb +3 -2
  25. data/lib/rcap/cap_1_1/info.rb +281 -217
  26. data/lib/rcap/cap_1_1/parameter.rb +35 -16
  27. data/lib/rcap/cap_1_1/point.rb +23 -9
  28. data/lib/rcap/cap_1_1/polygon.rb +38 -20
  29. data/lib/rcap/cap_1_1/resource.rb +106 -65
  30. data/lib/rcap/cap_1_2/alert.rb +224 -158
  31. data/lib/rcap/cap_1_2/area.rb +100 -67
  32. data/lib/rcap/cap_1_2/circle.rb +49 -24
  33. data/lib/rcap/cap_1_2/event_code.rb +3 -2
  34. data/lib/rcap/cap_1_2/geocode.rb +3 -2
  35. data/lib/rcap/cap_1_2/info.rb +285 -219
  36. data/lib/rcap/cap_1_2/parameter.rb +39 -19
  37. data/lib/rcap/cap_1_2/point.rb +23 -9
  38. data/lib/rcap/cap_1_2/polygon.rb +37 -20
  39. data/lib/rcap/cap_1_2/resource.rb +107 -67
  40. data/lib/rcap/config.rb +4 -0
  41. data/lib/rcap/utilities.rb +55 -2
  42. data/lib/rcap/validations.rb +2 -2
  43. data/lib/rcap/version.rb +1 -1
  44. data/rcap.gemspec +2 -2
  45. data/spec/cap_1_0/parameter_spec.rb +5 -1
  46. data/spec/cap_1_1/resource_spec.rb +6 -0
  47. data/spec/cap_1_2/alert_spec.rb +8 -0
  48. data/spec/cap_1_2/resource_spec.rb +8 -2
  49. metadata +11 -10
  50. data/README.rdoc +0 -247
  51. data/lib/config.rb +0 -2
@@ -8,58 +8,77 @@ module RCAP
8
8
 
9
9
  validates_presence_of( :name, :value )
10
10
 
11
- attr_accessor( :name, :value )
11
+ # @return [String]
12
+ attr_accessor( :name )
13
+ # @return [String]
14
+ attr_accessor( :value )
12
15
 
13
- XML_ELEMENT_NAME = "parameter" # :nodoc:
14
- NAME_ELEMENT_NAME = "valueName" # :nodoc:
15
- VALUE_ELEMENT_NAME = "value" # :nodoc:
16
+ XML_ELEMENT_NAME = "parameter"
17
+ NAME_ELEMENT_NAME = "valueName"
18
+ VALUE_ELEMENT_NAME = "value"
16
19
 
17
- XPATH = "cap:#{ XML_ELEMENT_NAME }" # :nodoc:
18
- NAME_XPATH = "cap:#{ NAME_ELEMENT_NAME }" # :nodoc:
19
- VALUE_XPATH = "cap:#{ VALUE_ELEMENT_NAME }" # :nodoc:
20
+ XPATH = "cap:#{ XML_ELEMENT_NAME }"
21
+ NAME_XPATH = "cap:#{ NAME_ELEMENT_NAME }"
22
+ VALUE_XPATH = "cap:#{ VALUE_ELEMENT_NAME }"
20
23
 
24
+ # @param [Hash] attributes
25
+ # @option attributes [Symbol] :name Parameter name
26
+ # @option attributes [Symbol] :value Parameter value
21
27
  def initialize( attributes = {} )
22
28
  @name = attributes[ :name ]
23
29
  @value = attributes[ :value ]
24
30
  end
25
31
 
26
- def to_xml_element # :nodoc:
32
+ # @return [REXML::Element]
33
+ def to_xml_element
27
34
  xml_element = REXML::Element.new( self.class::XML_ELEMENT_NAME )
28
- xml_element.add_element( self.class::NAME_ELEMENT_NAME ).add_text( self.name )
29
- xml_element.add_element( self.class::VALUE_ELEMENT_NAME ).add_text( self.value )
35
+ xml_element.add_element( self.class::NAME_ELEMENT_NAME ).add_text( @name )
36
+ xml_element.add_element( self.class::VALUE_ELEMENT_NAME ).add_text( @value )
30
37
  xml_element
31
38
  end
32
39
 
33
- def to_xml # :nodoc:
40
+ # @return [String]
41
+ def to_xml
34
42
  self.to_xml_element.to_s
35
43
  end
36
44
 
37
- def inspect # :nodoc:
38
- "#{ self.name }: #{ self.value }"
45
+ # @return [String]
46
+ def inspect
47
+ "#{ @name }: #{ @value }"
39
48
  end
40
49
 
41
50
  # Returns a string representation of the parameter of the form
42
51
  # name: value
52
+ #
53
+ # @return [String]
43
54
  def to_s
44
55
  self.inspect
45
56
  end
46
57
 
58
+ # @param [REXML::Element] parameter_xml_element
59
+ # @return [Parameter]
47
60
  def self.from_xml_element( parameter_xml_element ) # :nodoc:
48
61
  self.new( :name => RCAP.xpath_text( parameter_xml_element, self::NAME_XPATH, Alert::XMLNS ),
49
62
  :value => RCAP.xpath_text( parameter_xml_element, self::VALUE_XPATH, Alert::XMLNS ))
50
63
  end
51
64
 
52
65
  # Two parameters are equivalent if they have the same name and value.
66
+ #
67
+ # @param [Parameter] other
68
+ # @return [true, false]
53
69
  def ==( other )
54
- [ self.name, self.value ] == [ other.name, other.value ]
70
+ [ @name, @value ] == [ other.name, other.value ]
55
71
  end
56
72
 
57
- def to_h # :nodoc:
73
+ # @return [Hash]
74
+ def to_h
58
75
  RCAP.attribute_values_to_hash(
59
76
  [ @name, @value ])
60
77
  end
61
78
 
62
- def self.from_h( hash ) # :nodoc:
79
+ # @param [Hash] hash
80
+ # @return [Parameter]
81
+ def self.from_h( hash )
63
82
  key = hash.keys.first
64
83
  self.new( :name => key, :value => hash[ key ])
65
84
  end
@@ -11,13 +11,18 @@ module RCAP
11
11
  MAX_LATTITUDE = 90
12
12
  MIN_LATTITUDE = -90
13
13
 
14
+ # @return [Numeric]
14
15
  attr_accessor( :lattitude )
16
+ # @return [Numeric]
15
17
  attr_accessor( :longitude )
16
18
 
17
19
  validates_numericality_of( :lattitude, :longitude )
18
20
  validates_inclusion_of( :lattitude, :in => MIN_LATTITUDE..MAX_LATTITUDE )
19
21
  validates_inclusion_of( :longitude, :in => MIN_LONGITUDE..MAX_LONGITUDE)
20
22
 
23
+ # @param [Hash] attributes
24
+ # @option attributes [Numeric] :lattitude
25
+ # @option attributes [Numeric] :longitude
21
26
  def initialize( attributes = {} )
22
27
  @lattitude = attributes[ :lattitude ]
23
28
  @longitude = attributes[ :longitude ]
@@ -25,29 +30,38 @@ module RCAP
25
30
 
26
31
  # Returns a string representation of the point of the form
27
32
  # lattitude,longitude
33
+ #
34
+ # @return [String]
28
35
  def to_s
29
- "#{ self.lattitude },#{ self.longitude }"
36
+ "#{ @lattitude },#{ @longitude }"
30
37
  end
31
38
 
32
- def inspect # :nodoc:
39
+ # @return [String]
40
+ def inspect
33
41
  '('+self.to_s+')'
34
42
  end
35
43
 
36
44
  # Two points are equivalent if they have the same lattitude and longitude
45
+ #
46
+ # @param [Point] other
47
+ # @return [true, false]
37
48
  def ==( other )
38
- [ self.lattitude, self.longitude ] == [ other.lattitude, other.longitude ]
49
+ [ @lattitude, @longitude ] == [ other.lattitude, other.longitude ]
39
50
  end
40
51
 
41
- LATTITUDE_KEY = 'lattitude' # :nodoc:
42
- LONGITUDE_KEY = 'longitude' # :nodoc:
52
+ LATTITUDE_KEY = 'lattitude'
53
+ LONGITUDE_KEY = 'longitude'
43
54
 
44
- def to_h # :nodoc:
55
+ # @return [Hash]
56
+ def to_h
45
57
  RCAP.attribute_values_to_hash(
46
- [ LATTITUDE_KEY, self.lattitude ],
47
- [ LONGITUDE_KEY, self.longitude ])
58
+ [ LATTITUDE_KEY, @lattitude ],
59
+ [ LONGITUDE_KEY, @longitude ])
48
60
  end
49
61
 
50
- def self.from_h( point_hash ) # :nodoc:
62
+ # @param [Hash] point_hash
63
+ # @return [Point]
64
+ def self.from_h( point_hash )
51
65
  self.new( :lattitude => point_hash[ LATTITUDE_KEY ], :longitude => point_hash[ LONGITUDE_KEY ])
52
66
  end
53
67
  end
@@ -6,55 +6,69 @@ module RCAP
6
6
  class Polygon
7
7
  include Validation
8
8
 
9
- # Collection of Point objects.
9
+ # @return [Array<Point>] Collection of {Point} objects.
10
10
  attr_reader( :points )
11
11
 
12
12
  validates_collection_of( :points )
13
13
  validates_length_of( :points, :minimum => 3 )
14
14
  validates_equality_of_first_and_last( :points )
15
15
 
16
- XML_ELEMENT_NAME = 'polygon' # :nodoc:
17
- XPATH = "cap:#{ XML_ELEMENT_NAME }" # :nodoc:
18
-
16
+ XML_ELEMENT_NAME = 'polygon'
17
+ XPATH = "cap:#{ XML_ELEMENT_NAME }"
18
+
19
+ # @param [Hash] attributes
20
+ # @option attributes [Array<Point>] :points Collection of {Point} objects
19
21
  def initialize( attributes = {})
20
22
  @points = Array( attributes[ :points ])
21
23
  end
22
24
 
23
- # Creates a new Point object and adds it to the points array. The
24
- # poitn_attributes are passed as a parameter to Point.new.
25
+ # Creates a new Point object and adds it to the points array.
26
+ #
27
+ # @see Point#initialize
25
28
  def add_point( point_attributes = {})
26
29
  point = Point.new( point_attributes )
27
- self.points << point
30
+ @points << point
28
31
  point
29
32
  end
30
33
 
31
34
  # Returns a string representation of the polygon of the form
32
- # points[0] points[1] points[2] ...
35
+ # points[0] points[1] points[2] ...
33
36
  # where each point is formatted with Point#to_s
34
37
  def to_s
35
38
  @points.join( ' ' )
36
39
  end
37
40
 
38
- def inspect # :nodoc:
41
+ # @return [String]
42
+ def inspect
39
43
  "(#{ @points.map{|point| point.inspect}.join(', ')})"
40
44
  end
41
45
 
42
- def to_xml_element # :nodoc:
46
+ # @return [REXML::Element]
47
+ def to_xml_element
43
48
  xml_element = REXML::Element.new( XML_ELEMENT_NAME )
44
49
  xml_element.add_text( self.to_s )
45
50
  xml_element
46
51
  end
47
52
 
53
+ # @return [String]
54
+ def to_xml
55
+ self.to_xml_element.to_s
56
+ end
57
+
48
58
  # Two polygons are equivalent if their collection of points is equivalent.
59
+ #
60
+ # @return [true,false]
49
61
  def ==( other )
50
- self.points == other.points
62
+ @points == other.points
51
63
  end
52
64
 
53
- def self.parse_polygon_string( polygon_string ) # :nodoc:
65
+ # @return [Array<Array(Numeric,Numeric)>]
66
+ def self.parse_polygon_string( polygon_string )
54
67
  polygon_string.split( ' ' ).map{ |coordinate_string| coordinate_string.split( ',' ).map{|coordinate| coordinate.to_f }}
55
68
  end
56
69
 
57
- def self.from_xml_element( polygon_xml_element ) # :nodoc:
70
+ # @return [Polygon]
71
+ def self.from_xml_element( polygon_xml_element )
58
72
  if !polygon_xml_element.text.nil? && !polygon_xml_element.text.empty?
59
73
  coordinates = self.parse_polygon_string( polygon_xml_element.text )
60
74
  points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}
@@ -65,21 +79,25 @@ module RCAP
65
79
  end
66
80
 
67
81
 
68
- def to_yaml( options = {} ) # :nodoc:
69
- self.points.map{ |point| [ point.lattitude, point.longitude ]}.to_yaml( options )
82
+ # @return [String]
83
+ def to_yaml( options = {} )
84
+ @points.map{ |point| [ point.lattitude, point.longitude ]}.to_yaml( options )
70
85
  end
71
86
 
72
- def self.from_yaml_data( polygon_yaml_data ) # :nodoc:
87
+ # @return [Polygon]
88
+ def self.from_yaml_data( polygon_yaml_data )
73
89
  self.new( :points => Array( polygon_yaml_data ).map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )})
74
90
  end
75
91
 
76
- POINTS_KEY = 'points' # :nodoc:
92
+ POINTS_KEY = 'points'
77
93
 
78
- def to_h # :nodoc:
79
- { POINTS_KEY => self.points.map{ |point| point.to_h }}
94
+ # @return [Hash]
95
+ def to_h
96
+ { POINTS_KEY => @points.map{ |point| point.to_h }}
80
97
  end
81
98
 
82
- def self.from_h( polygon_hash ) # :nodoc:
99
+ # @return [Polygon]
100
+ def self.from_h( polygon_hash )
83
101
  self.new( :points => polygon_hash[ POINTS_KEY ].map{ |point_hash| Point.from_h( point_hash )})
84
102
  end
85
103
  end
@@ -6,36 +6,44 @@ module RCAP
6
6
  class Resource
7
7
  include Validation
8
8
 
9
- # Resource Description
9
+ # @return [String] Resource Description
10
10
  attr_accessor( :resource_desc )
11
+ # @return [String]
11
12
  attr_accessor( :mime_type )
12
- # Expressed in bytes
13
+ # @return [Integer] Expressed in bytes
13
14
  attr_accessor( :size )
14
- # Resource location
15
+ # @return [String] Resource location
15
16
  attr_accessor( :uri )
16
- # Dereferenced URI - contents of URI Base64 encoded
17
+ # @return [String] Dereferenced URI - contents of URI Base64 encoded
17
18
  attr_accessor( :deref_uri )
18
- # SHA-1 hash of contents of resource
19
+ # @return [String] SHA-1 hash of contents of resource
19
20
  attr_accessor( :digest )
20
21
 
21
22
  validates_presence_of( :resource_desc )
22
23
 
23
- XML_ELEMENT_NAME = 'resource' # :nodoc:
24
- MIME_TYPE_ELEMENT_NAME = 'mimeType' # :nodoc:
25
- SIZE_ELEMENT_NAME = 'size' # :nodoc:
26
- URI_ELEMENT_NAME = 'uri' # :nodoc:
27
- DEREF_URI_ELEMENT_NAME = 'derefUri' # :nodoc:
28
- DIGEST_ELEMENT_NAME = 'digest' # :nodoc:
29
- RESOURCE_DESC_ELEMENT_NAME = 'resourceDesc' # :nodoc:
30
-
31
- XPATH = "cap:#{ XML_ELEMENT_NAME }" # :nodoc:
32
- MIME_TYPE_XPATH = "cap:#{ MIME_TYPE_ELEMENT_NAME }" # :nodoc:
33
- SIZE_XPATH = "cap:#{ SIZE_ELEMENT_NAME }" # :nodoc:
34
- URI_XPATH = "cap:#{ URI_ELEMENT_NAME }" # :nodoc:
35
- DEREF_URI_XPATH = "cap:#{ DEREF_URI_ELEMENT_NAME }" # :nodoc:
36
- DIGEST_XPATH = "cap:#{ DIGEST_ELEMENT_NAME }" # :nodoc:
37
- RESOURCE_DESC_XPATH = "cap:#{ RESOURCE_DESC_ELEMENT_NAME }" # :nodoc:
38
-
24
+ XML_ELEMENT_NAME = 'resource'
25
+ MIME_TYPE_ELEMENT_NAME = 'mimeType'
26
+ SIZE_ELEMENT_NAME = 'size'
27
+ URI_ELEMENT_NAME = 'uri'
28
+ DEREF_URI_ELEMENT_NAME = 'derefUri'
29
+ DIGEST_ELEMENT_NAME = 'digest'
30
+ RESOURCE_DESC_ELEMENT_NAME = 'resourceDesc'
31
+
32
+ XPATH = "cap:#{ XML_ELEMENT_NAME }"
33
+ MIME_TYPE_XPATH = "cap:#{ MIME_TYPE_ELEMENT_NAME }"
34
+ SIZE_XPATH = "cap:#{ SIZE_ELEMENT_NAME }"
35
+ URI_XPATH = "cap:#{ URI_ELEMENT_NAME }"
36
+ DEREF_URI_XPATH = "cap:#{ DEREF_URI_ELEMENT_NAME }"
37
+ DIGEST_XPATH = "cap:#{ DIGEST_ELEMENT_NAME }"
38
+ RESOURCE_DESC_XPATH = "cap:#{ RESOURCE_DESC_ELEMENT_NAME }"
39
+
40
+ # @param [Hash{Symbol => Object}] attributes
41
+ # @option attributes [String] :mime_type
42
+ # @option attributes [Numeric] :size Size in bytes
43
+ # @option attributes [String] :uri
44
+ # @option attributes [String] :deref_uri
45
+ # @option attributes [String] :digest
46
+ # @option attributes [String] :resource_desc
39
47
  def initialize( attributes = {} )
40
48
  @mime_type = attributes[ :mime_type ]
41
49
  @size = attributes[ :size ]
@@ -45,57 +53,83 @@ module RCAP
45
53
  @resource_desc = attributes[ :resource_desc ]
46
54
  end
47
55
 
48
- def to_xml_element # :nodoc:
56
+ # @return [REXML::Element]
57
+ def to_xml_element
49
58
  xml_element = REXML::Element.new( XML_ELEMENT_NAME )
50
- xml_element.add_element( RESOURCE_DESC_ELEMENT_NAME ).add_text( self.resource_desc )
51
- xml_element.add_element( MIME_TYPE_ELEMENT_NAME ).add_text( self.mime_type ) if self.mime_type
52
- xml_element.add_element( SIZE_ELEMENT_NAME ).add_text( self.size.to_s ) if self.size
53
- xml_element.add_element( URI_ELEMENT_NAME ).add_text( self.uri ) if self.uri
54
- xml_element.add_element( DEREF_URI_ELEMENT_NAME ).add_text( self.deref_uri ) if self.deref_uri
55
- xml_element.add_element( DIGEST_ELEMENT_NAME ).add_text( self.digest ) if self.digest
59
+ xml_element.add_element( RESOURCE_DESC_ELEMENT_NAME ).add_text( @resource_desc )
60
+ xml_element.add_element( MIME_TYPE_ELEMENT_NAME ).add_text( @mime_type ) if @mime_type
61
+ xml_element.add_element( SIZE_ELEMENT_NAME ).add_text( @size.to_s ) if @size
62
+ xml_element.add_element( URI_ELEMENT_NAME ).add_text( @uri ) if @uri
63
+ xml_element.add_element( DEREF_URI_ELEMENT_NAME ).add_text( @deref_uri ) if @deref_uri
64
+ xml_element.add_element( DIGEST_ELEMENT_NAME ).add_text( @digest ) if @digest
56
65
  xml_element
57
66
  end
58
67
 
59
68
  # If size is defined returns the size in kilobytes
69
+ # @return [Float]
60
70
  def size_in_kb
61
- if self.size
62
- self.size.to_f/1024
71
+ if @size
72
+ @size.to_f/1024
63
73
  end
64
74
  end
65
75
 
66
- def to_xml # :nodoc:
76
+ # @return [String]
77
+ def to_xml
67
78
  self.to_xml_element.to_s
68
79
  end
69
80
 
70
- def inspect # :nodoc:
71
- [ self.resource_desc, self.uri, self.mime_type, self.size ? format( "%.1fKB", self.size_in_kb ) : nil ].compact.join(' - ')
81
+ # @return [String]
82
+ def inspect
83
+ [ @resource_desc, @uri, @mime_type, @size ? format( "%.1fKB", @size_in_kb ) : nil ].compact.join(' - ')
72
84
  end
73
85
 
74
86
  # Returns a string representation of the resource of the form
75
87
  # resource_desc
88
+ #
89
+ # @return [String]
76
90
  def to_s
77
- self.resource_desc
91
+ @resource_desc
78
92
  end
79
93
 
80
94
  # Retrieves the content at uri and stores it in deref_uri as Base64 encoded text. It will also
81
- # calculate the digest on the encoded data using SHA1 and set the size.
95
+ # calculate the {#digest} on the encoded data using SHA1 and set the {#size}.
82
96
  #
83
97
  # This uses the open-uri[http://ruby-doc.org/stdlib/libdoc/open-uri/rdoc/index.html] Ruby API
84
- # to open and read the content.
98
+ # to open and read the content. This method may throw an exception due to any number of network
99
+ # related issue so please handle accordingly.
100
+ #
101
+ # Returns an array containing the size (in bytes) and SHA-1 hash.
102
+ #
103
+ # @return [Array(Integer,String)]
85
104
  def dereference_uri!
86
105
  content = URI.parse( self.uri ).read
87
106
  @deref_uri = Base64.encode64( content )
88
107
  self.calculate_hash_and_size
89
108
  end
90
109
 
110
+ # Calculates the SHA-1 hash and size of the contents of {#deref_uri}.
111
+ # Returns an array containing the size (in bytes) and SHA-1 hash if
112
+ # {#deref_uri} is present otherwise returns nil.
113
+ #
114
+ # @return [nil,Array(Integer,String)]
91
115
  def calculate_hash_and_size
92
116
  if @deref_uri
93
117
  @digest = Digest::SHA1.hexdigest( @deref_uri )
94
118
  @size = @deref_uri.bytesize
119
+ [ @size, @digest ]
95
120
  end
96
121
  end
97
122
 
98
- def self.from_xml_element( resource_xml_element ) # :nodoc:
123
+ # The decoded contents of {#deref_uri} if present otherwise nil.
124
+ #
125
+ # @return [nil,String]
126
+ def decoded_deref_uri
127
+ Base64.decode64( @deref_uri ) if @deref_uri
128
+ end
129
+
130
+ # @param [REXML::Element] resource_xml_element
131
+ # @return [Resource]
132
+ def self.from_xml_element( resource_xml_element )
99
133
  resource = self.new( :resource_desc => RCAP.xpath_text( resource_xml_element, RESOURCE_DESC_XPATH, Alert::XMLNS ),
100
134
  :uri => RCAP.xpath_text( resource_xml_element, URI_XPATH, Alert::XMLNS ),
101
135
  :mime_type => RCAP.xpath_text( resource_xml_element, MIME_TYPE_XPATH, Alert::XMLNS ),
@@ -104,24 +138,28 @@ module RCAP
104
138
  :digest => RCAP.xpath_text( resource_xml_element, DIGEST_XPATH, Alert::XMLNS ))
105
139
  end
106
140
 
107
- RESOURCE_DESC_YAML = "Resource Description" # :nodoc:
108
- URI_YAML = "URI" # :nodoc:
109
- MIME_TYPE_YAML = "Mime Type" # :nodoc:
110
- DEREF_URI_YAML = "Derefrenced URI Data" # :nodoc:
111
- SIZE_YAML = "Size" # :nodoc:
112
- DIGEST_YAML = "Digest" # :nodoc:
141
+ RESOURCE_DESC_YAML = "Resource Description"
142
+ URI_YAML = "URI"
143
+ MIME_TYPE_YAML = "Mime Type"
144
+ DEREF_URI_YAML = "Derefrenced URI Data"
145
+ SIZE_YAML = "Size"
146
+ DIGEST_YAML = "Digest"
113
147
 
114
- def to_yaml( options = {} ) # :nodoc:
148
+ # @param [Hash] options
149
+ # @return [String]
150
+ def to_yaml( options = {} )
115
151
  RCAP.attribute_values_to_hash(
116
- [ RESOURCE_DESC_YAML, self.resource_desc ],
117
- [ URI_YAML, self.uri ],
118
- [ MIME_TYPE_YAML, self.mime_type ],
119
- [ DEREF_URI_YAML, self.deref_uri ],
120
- [ SIZE_YAML, self.size ],
121
- [ DIGEST_YAML, self.digest ]).to_yaml( options )
152
+ [ RESOURCE_DESC_YAML, @resource_desc ],
153
+ [ URI_YAML, @uri ],
154
+ [ MIME_TYPE_YAML, @mime_type ],
155
+ [ DEREF_URI_YAML, @deref_uri ],
156
+ [ SIZE_YAML, @size ],
157
+ [ DIGEST_YAML, @digest ]).to_yaml( options )
122
158
  end
123
159
 
124
- def self.from_yaml_data( resource_yaml_data ) # :nodoc:
160
+ # @param [Hash] resource_yaml_data
161
+ # @return [Resource]
162
+ def self.from_yaml_data( resource_yaml_data )
125
163
  self.new(
126
164
  :resource_desc => reource_yaml_data[ RESOURCE_DESC_YAML ],
127
165
  :uri => reource_yaml_data[ URI_YAML ],
@@ -132,24 +170,27 @@ module RCAP
132
170
  )
133
171
  end
134
172
 
135
- RESOURCE_DESC_KEY = 'resource_desc' # :nodoc:
136
- URI_KEY = 'uri' # :nodoc:
137
- MIME_TYPE_KEY = 'mime_type' # :nodoc:
138
- DEREF_URI_KEY = 'deref_uri' # :nodoc:
139
- SIZE_KEY = 'size' # :nodoc:
140
- DIGEST_KEY = 'digest' # :nodoc:
173
+ RESOURCE_DESC_KEY = 'resource_desc'
174
+ URI_KEY = 'uri'
175
+ MIME_TYPE_KEY = 'mime_type'
176
+ DEREF_URI_KEY = 'deref_uri'
177
+ SIZE_KEY = 'size'
178
+ DIGEST_KEY = 'digest'
141
179
 
142
- def to_h # :nodoc:
180
+ # @return [Hash]
181
+ def to_h
143
182
  RCAP.attribute_values_to_hash(
144
- [ RESOURCE_DESC_KEY, self.resource_desc ],
145
- [ URI_KEY, self.uri],
146
- [ MIME_TYPE_KEY, self.mime_type],
147
- [ DEREF_URI_KEY, self.deref_uri],
148
- [ SIZE_KEY, self.size ],
149
- [ DIGEST_KEY, self.digest ])
183
+ [ RESOURCE_DESC_KEY, @resource_desc ],
184
+ [ URI_KEY, @uri],
185
+ [ MIME_TYPE_KEY, @mime_type],
186
+ [ DEREF_URI_KEY, @deref_uri],
187
+ [ SIZE_KEY, @size ],
188
+ [ DIGEST_KEY, @digest ])
150
189
  end
151
190
 
152
- def self.from_h( resource_hash ) # :nodoc:
191
+ # @param [Hash] resource_hash
192
+ # @return [Resource]
193
+ def self.from_h( resource_hash )
153
194
  self.new(
154
195
  :resource_desc => resource_hash[ RESOURCE_DESC_KEY ],
155
196
  :uri => resource_hash[ URI_KEY ],