Module: RIO::Ext::YAML::Input
- Defined in:
- lib/rio/ext/yaml.rb
Instance Method Summary collapse
- #add_filters ⇒ Object
- #apto_(arg) ⇒ Object
- #cpto_(arg) ⇒ Object
- #cpto_array_(array) ⇒ Object
- #cpto_io_(ioarg) ⇒ Object
- #cpto_obj_(arg) ⇒ Object
- #cpto_string_(string) ⇒ Object
- #each_(&block) ⇒ Object
- #each_rec_(&block) ⇒ Object
- #get_(arg = nil) ⇒ Object
- #getobj ⇒ Object
- #load ⇒ Object
Instance Method Details
#add_filters ⇒ Object
125 126 127 128 |
# File 'lib/rio/ext/yaml.rb', line 125 def add_filters cx['yaml_close_eof'],cx['closeoneof'] = cx['closeoneof'],false super end |
#apto_(arg) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/rio/ext/yaml.rb', line 73 def apto_(arg) case arg when ::Array,::String then super when ::IO,::StringIO then cpto_io_(arg) else super end end |
#cpto_(arg) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/rio/ext/yaml.rb', line 64 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_array_(array) ⇒ Object
93 94 95 96 97 |
# File 'lib/rio/ext/yaml.rb', line 93 def cpto_array_(array) self.each { |el| array << el } end |
#cpto_io_(ioarg) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/rio/ext/yaml.rb', line 80 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_obj_(arg) ⇒ Object
88 89 90 91 92 |
# File 'lib/rio/ext/yaml.rb', line 88 def cpto_obj_(arg) self.each { |obj| } end |
#cpto_string_(string) ⇒ Object
98 99 100 |
# File 'lib/rio/ext/yaml.rb', line 98 def cpto_string_(string) string << ::YAML.dump_stream(self.contents) end |
#each_(&block) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/rio/ext/yaml.rb', line 129 def each_(&block) #old_close_eof,cx['closeoneof'] = cx['closeoneof'],false super cx['closeoneof'] = cx.delete('yaml_close_eof') if closeoneof? add_filter(Filter::CloseOnEOF) ioh.oncloseproc = proc { self.on_closeoneof } end closeoneof? ? ioh.close_on_eof_(self) : self end |
#each_rec_(&block) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/rio/ext/yaml.rb', line 109 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
101 102 103 104 105 106 107 108 |
# File 'lib/rio/ext/yaml.rb', line 101 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
121 122 123 |
# File 'lib/rio/ext/yaml.rb', line 121 def getobj() getrec() end |
#load ⇒ Object
118 119 120 |
# File 'lib/rio/ext/yaml.rb', line 118 def load() getrec() end |