Module: BioVcf::ConvertStringToValue

Defined in:
lib/bio-vcf/utils.rb

Class Method Summary collapse

Class Method Details

.convert(str) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bio-vcf/utils.rb', line 12

def self::convert str
  if str =~ /,/
    str.split(/,/).map { |item| convert(item) }
  else
    if integer?(str)
      str.to_i 
    else
      if float?(str)
        str.to_f 
      else
        str
      end
    end
  end
end

.float?(str) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/bio-vcf/utils.rb', line 8

def self::float?(str)
  !!Float(str) rescue false
end

.integer?(str) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/bio-vcf/utils.rb', line 4

def self::integer?(str)
  !!Integer(str) rescue false
end