diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-07-09 08:45:46 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-07-09 08:45:46 -0700 |
commit | c1e912caf966bc29b346c193f1b74e23e0f66781 (patch) | |
tree | 70ddb27b5d8f32766e89fe6b86375373daedf013 /lib/ffi_yajl/ffi/parser.rb | |
parent | 8fabdd3fddbd222109976fddb0d38255a9490f1d (diff) | |
download | ffi-yajl-c1e912caf966bc29b346c193f1b74e23e0f66781.tar.gz |
remaining autofixable cops
Diffstat (limited to 'lib/ffi_yajl/ffi/parser.rb')
-rw-r--r-- | lib/ffi_yajl/ffi/parser.rb | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb index d0d152a..e3226c0 100644 --- a/lib/ffi_yajl/ffi/parser.rb +++ b/lib/ffi_yajl/ffi/parser.rb @@ -23,34 +23,32 @@ module FFI_Yajl module FFI module Parser - def set_value(val) - case stack.last - when Hash - raise FFI_Yajl::ParseError.new("internal error: missing key in parse") if key.nil? - if @opts[:unique_key_checking] && stack.last.has_key?(key) - raise FFI_Yajl::ParseError.new("repeated key: #{key}") - end - stack.last[key] = val - when Array - stack.last.push(val) - else - stack.push(val) + def set_value(val) + case stack.last + when Hash + raise FFI_Yajl::ParseError.new("internal error: missing key in parse") if key.nil? + if @opts[:unique_key_checking] && stack.last.key?(key) + raise FFI_Yajl::ParseError.new("repeated key: #{key}") end + stack.last[key] = val + when Array + stack.last.push(val) + else + stack.push(val) end + end - def stack_pop - if stack.length > 1 - set_value( stack.pop ) - end - end + def stack_pop + set_value( stack.pop ) if stack.length > 1 + end - def key_push - key_stack.push(key) - end + def key_push + key_stack.push(key) + end - def key_pop - @key = key_stack.pop - end + def key_pop + @key = key_stack.pop + end def setup_callbacks @null_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx| @@ -85,7 +83,7 @@ module FFI_Yajl end @start_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx| key_push # for key => { } case, save the key - stack.push(Hash.new) + stack.push({}) 1 end @map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen| @@ -101,7 +99,7 @@ module FFI_Yajl end @start_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx| key_push # for key => [ ] case, save the key - stack.push(Array.new) + stack.push([]) 1 end @end_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx| |