roxo 0.1.7 → 0.1.8
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/lib/roxo.rb +4 -4
- data/roxo.gemspec +1 -1
- metadata +2 -2
data/lib/roxo.rb
CHANGED
@@ -30,11 +30,11 @@ class ROXO
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def terminal?
|
33
|
-
@children.
|
33
|
+
@children.blank? and @attributes.blank?
|
34
34
|
end # A node is terminal if we can't descend any further
|
35
35
|
|
36
36
|
def <=>(other)
|
37
|
-
return
|
37
|
+
return -1 unless (self.class == other.class)
|
38
38
|
return z unless (z = self.__attributes <=> other.__attributes).zero?
|
39
39
|
return z unless (z = self.value <=> other.value).zero?
|
40
40
|
return z unless (z = self.name <=> other.name).zero?
|
@@ -46,7 +46,6 @@ class ROXO
|
|
46
46
|
def ==(o)
|
47
47
|
self.<=>(o) == 0
|
48
48
|
end
|
49
|
-
|
50
49
|
|
51
50
|
def method_missing(sym, *args)
|
52
51
|
if terminal? # Proxy all method calls to the wrapped object.
|
@@ -54,7 +53,8 @@ class ROXO
|
|
54
53
|
elsif sym.to_s[-1..-1]=="?" # re-dispatch without question mark, interpret result as a boolean.
|
55
54
|
return %w{yes true t y}.include?(send(sym.to_s[0..-2].to_sym, *args).downcase)
|
56
55
|
elsif @children[sym]
|
57
|
-
|
56
|
+
x = self.class.new(@children[sym].first)
|
57
|
+
return x.terminal? ? x.value : x
|
58
58
|
elsif @attributes[sym.to_s]
|
59
59
|
return @attributes[sym.to_s]
|
60
60
|
elsif @children[sing = sym.to_s.singularize.to_sym]
|
data/roxo.gemspec
CHANGED