rexle 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rexle.rb +11 -2
  2. metadata +1 -1
data/lib/rexle.rb CHANGED
@@ -134,7 +134,6 @@ class Rexle
134
134
  end
135
135
  end
136
136
 
137
- #a.shift # added by jr 171110
138
137
  rlist = rlist.flatten(1) unless not(rlist.is_a? Array) or (rlist.length > 1 and rlist[0].is_a? Array)
139
138
  rlist = [rlist] if rlist.is_a? Rexle::Element
140
139
  rlist
@@ -150,7 +149,17 @@ class Rexle
150
149
 
151
150
  alias add add_element
152
151
 
153
- def add_attribute(h={}) @attributes.merge! h end
152
+ def add_attribute(*x)
153
+
154
+ procs = {
155
+ Hash: lambda {|x| x[0] || {}},
156
+ String: lambda {|x| Hash[*x]}
157
+ }
158
+ h = procs[x[0].class.to_s.to_sym].call(x)
159
+
160
+ @attributes.merge! h
161
+ end
162
+
154
163
  def add_text(s) @value = s; self end
155
164
  def attributes() @attributes end
156
165
  def children() @child_elements end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors: []
7
7