Class: Altsv

Inherits:
Object
  • Object
show all
Defined in:
lib/altsv.rb,
lib/altsv/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.dump(value) ⇒ Object



34
35
36
# File 'lib/altsv.rb', line 34

def dump(value)
  dump_native value
end

.load(path_or_io) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/altsv.rb', line 23

def load(path_or_io)
  case path_or_io
  when String
    File.open(path_or_io){|f| parse f}
  when IO
    parse(path_or_io)
  else
    raise ArgumentError, "#{name}.#{__method__} only accepts IO or path."
  end
end

.parse(input) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/altsv.rb', line 12

def parse(input)
  case input
  when String
    parse_native input
  when StringIO
    parse_native input.string
  when IO
    input.each_line.map{|line| parse_line_native line}
  end
end