eeml-simple 0.1.1 → 0.2.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.
- data/README +1 -1
- data/lib/eeml/environment.rb +72 -1
- metadata +2 -2
data/README
CHANGED
@@ -9,7 +9,7 @@ Author: James Smith (james@floppy.org.uk / http://www.floppy.org.uk)
|
|
9
9
|
|
10
10
|
Homepage: http://github.com/Floppy/eeml-ruby
|
11
11
|
|
12
|
-
Documentation: http://
|
12
|
+
Documentation: http://rdoc.info/projects/Floppy/eeml-ruby
|
13
13
|
|
14
14
|
== INSTALLATION
|
15
15
|
|
data/lib/eeml/environment.rb
CHANGED
@@ -22,7 +22,78 @@ module EEML
|
|
22
22
|
env = Environment.new
|
23
23
|
# Read data items
|
24
24
|
REXML::XPath.each(doc, "/eeml/environment/data") do |node|
|
25
|
-
|
25
|
+
data = EEML::Data.new(node.elements['value'].text.to_f)
|
26
|
+
# Read data tags
|
27
|
+
REXML::XPath.each(node, "tag") do |tag|
|
28
|
+
text = tag.text if(tag.text)
|
29
|
+
data.tags << text
|
30
|
+
end
|
31
|
+
data.max_value = node.elements["value"].attributes["maxValue"] if(node.elements["value"].attributes["maxValue"])
|
32
|
+
data.min_value = node.elements["value"].attributes["minValue"] if(node.elements["value"].attributes["minValue"])
|
33
|
+
# Load tags into data object
|
34
|
+
env << data
|
35
|
+
|
36
|
+
end
|
37
|
+
# Parse attributes
|
38
|
+
# Read creator
|
39
|
+
env.creator = doc.root.elements["environment"].attributes["creator"] if(doc.root.elements["environment"].attributes["creator"])
|
40
|
+
# Read id
|
41
|
+
env.id = doc.root.elements["environment"].attributes["id"] if(doc.root.elements["environment"].attributes["creator"])
|
42
|
+
|
43
|
+
# Read created
|
44
|
+
env.updated_at = Time.parse(doc.root.elements["environment"].attributes["updated"]) if(doc.root.elements["environment"].attributes["updated"])
|
45
|
+
|
46
|
+
# Parse environment elements
|
47
|
+
# Read title
|
48
|
+
|
49
|
+
env.title = doc.root.elements["//title"].text if(doc.root.elements["//title"])
|
50
|
+
|
51
|
+
# Read description
|
52
|
+
env.description = doc.root.elements["//description"].text if(doc.root.elements["//description"])
|
53
|
+
|
54
|
+
# Read email
|
55
|
+
env.email = doc.root.elements["//email"].text if(doc.root.elements["//email"])
|
56
|
+
|
57
|
+
# Read feed
|
58
|
+
env.feed = doc.root.elements["//feed"].text if(doc.root.elements["//feed"])
|
59
|
+
|
60
|
+
# Read icon
|
61
|
+
env.icon = doc.root.elements["//icon"].text if(doc.root.elements["//icon"])
|
62
|
+
|
63
|
+
# Read website
|
64
|
+
env.website = doc.root.elements["//website"].text if(doc.root.elements["//website"])
|
65
|
+
|
66
|
+
# Get the location element
|
67
|
+
if (doc.root.elements["///location"])
|
68
|
+
l_element = doc.root.elements["///location"]
|
69
|
+
# Get the domain - :physical or :virtual
|
70
|
+
if(l_element.attributes["domain"] == "physical")
|
71
|
+
loc = EEML::Location.new(:physical)
|
72
|
+
else
|
73
|
+
loc = EEML::Location.new(:virtual)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Get the exposure - :indoor or :outdoor
|
77
|
+
if(l_element.attributes["exposure"] == "indoor")
|
78
|
+
loc.exposure = :indoor
|
79
|
+
else
|
80
|
+
loc.exposure = :outdoor
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get the disposition - :fixed or :mobile
|
84
|
+
if(l_element.attributes["disposition"] == "mobile")
|
85
|
+
loc.disposition = :mobile
|
86
|
+
else
|
87
|
+
loc.disposition = :fixed
|
88
|
+
end
|
89
|
+
|
90
|
+
# Get the location elements
|
91
|
+
loc.name = doc.root.elements["///name"].text
|
92
|
+
loc.lat = doc.root.elements["///lat"].text.to_i
|
93
|
+
loc.lon = doc.root.elements["///lon"].text.to_i
|
94
|
+
loc.ele = doc.root.elements["///ele"].text.to_f
|
95
|
+
|
96
|
+
env.location = loc
|
26
97
|
end
|
27
98
|
# Done
|
28
99
|
return env
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eeml-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-10 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|