Module: RIO::Ext::YAML::Input
- Defined in:
- lib/rio/ext/yaml.rb
Instance Method Summary collapse
- #apto_(arg) ⇒ Object
- #cpto_(arg) ⇒ Object
- #cpto_io_(ioarg) ⇒ Object
- #cpto_string_(string) ⇒ Object
- #each_rec_(&block) ⇒ Object
- #get_(arg = nil) ⇒ Object
- #getobj ⇒ Object
- #load ⇒ Object
Instance Method Details
#apto_(arg) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/rio/ext/yaml.rb', line 62 def apto_(arg) case arg when ::Array,::String then super when ::IO,::StringIO then cpto_io_(arg) else super end end |
#cpto_(arg) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/rio/ext/yaml.rb', line 53 def cpto_(arg) #p callstr('cpto_',arg.inspect) case arg when ::Array,::String then super when ::IO,::StringIO then cpto_io_(arg) else super end end |
#cpto_io_(ioarg) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/rio/ext/yaml.rb', line 69 def cpto_io_(ioarg) recs = self.to_a if recs.size == 1 YAML.dump(recs[0],ioarg) else YAML.dump(recs,ioarg) end end |
#cpto_string_(string) ⇒ Object
77 78 79 |
# File 'lib/rio/ext/yaml.rb', line 77 def cpto_string_(string) string << ::YAML.dump_stream(self.contents) end |
#each_rec_(&block) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/rio/ext/yaml.rb', line 88 def each_rec_(&block) case cx['stream_itertype'] when 'lines' then super when 'records' then ::YAML.load_documents(self.ioh,&block) when 'rows' then ::YAML.load_documents(self.ioh) { |obj| yield obj.to_yaml } else ::YAML.load_documents(self.ioh,&block) end self end |
#get_(arg = nil) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/rio/ext/yaml.rb', line 80 def get_(arg=nil) case cx['stream_itertype'] when 'lines' then super when 'records' then ::YAML.load(self.ioh) when 'rows' then ::YAML.dump(::YAML.load(self.ioh)) else ::YAML.load(self.ioh) end end |
#getobj ⇒ Object
100 101 102 |
# File 'lib/rio/ext/yaml.rb', line 100 def getobj() getrec() end |
#load ⇒ Object
97 98 99 |
# File 'lib/rio/ext/yaml.rb', line 97 def load() getrec() end |