bcl 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -169,19 +169,16 @@ class Component
169
169
  @tags << tag
170
170
  end
171
171
 
172
- def add_attribute(name, value, units)
172
+ def add_attribute(name, value, units, datatype = nil)
173
173
  attr = AttrStruct.new
174
174
  attr.name = name
175
175
  attr.value = value
176
-
177
- if value.is_a? Fixnum
178
- attr.datatype = "int"
179
- elsif value.is_a? Float
180
- attr.datatype = "float"
176
+
177
+ if !datatype.nil?
178
+ attr.datatype = datatype
181
179
  else
182
- attr.datatype = "string"
180
+ attr.datatype = get_datatype(value)
183
181
  end
184
-
185
182
  attr.units = units
186
183
 
187
184
  @attributes << attr
@@ -433,10 +430,20 @@ class Component
433
430
  }
434
431
 
435
432
  xmlfile.close
436
- end
437
-
438
- private
439
-
433
+ end
434
+
435
+ def get_attribute(attribute_name)
436
+ result = nil
437
+ @attributes.each do |attr|
438
+ if attr.name == attribute_name
439
+ result = attr
440
+ end
441
+ end
442
+
443
+ result
444
+
445
+ end
446
+
440
447
  #return the title case of the string
441
448
  def tc(input)
442
449
  val = input.gsub(/\b\w/){$&.upcase}
@@ -445,6 +452,27 @@ class Component
445
452
  end
446
453
  return val
447
454
  end
455
+
456
+ private
457
+
458
+ def get_datatype(input_value)
459
+ dt = 'undefined'
460
+
461
+ # simple method to test if the input_value is a string, float, or integer.
462
+ # First convert the value back to a string for testing (in case it was passed as a float/integer)
463
+ test = input_value.to_s
464
+ input_value = test.match('\.').nil? ? Integer(test) : Float(test) rescue test.to_s
465
+
466
+ if input_value.is_a?(Fixnum) || input_value.is_a?(Bignum)
467
+ dt = "int"
468
+ elsif input_value.is_a?(Float)
469
+ dt = "float"
470
+ else
471
+ dt = "string"
472
+ end
473
+
474
+ dt
475
+ end
448
476
 
449
477
  end
450
478
 
@@ -23,6 +23,7 @@ require 'zlib' #gem install zliby
23
23
  require 'archive/tar/minitar' #gem install archive-tar-minitar
24
24
 
25
25
  module BCL
26
+
26
27
  module_function
27
28
 
28
29
  def tarball(destination, paths)
@@ -18,5 +18,5 @@
18
18
  ######################################################################
19
19
 
20
20
  module BCL
21
- VERSION = "0.1.6"
22
- end
21
+ VERSION = "0.1.7"
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-02-08 00:00:00.000000000 Z
15
+ date: 2013-02-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: uuid
@@ -123,12 +123,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -2169455961606084983
126
129
  required_rubygems_version: !ruby/object:Gem::Requirement
127
130
  none: false
128
131
  requirements:
129
132
  - - ! '>='
130
133
  - !ruby/object:Gem::Version
131
134
  version: '0'
135
+ segments:
136
+ - 0
137
+ hash: -2169455961606084983
132
138
  requirements: []
133
139
  rubyforge_project:
134
140
  rubygems_version: 1.8.23