lib/ronin/binary/hexdump/parser.rb in ronin-support-0.5.0 vs lib/ronin/binary/hexdump/parser.rb in ronin-support-0.5.1

- old
+ new

@@ -135,14 +135,12 @@ def initialize(options={}) @format = options[:format] @encoding = options[:encoding] @type = case @encoding - when :floats, :doubles - :float - else - :integer + when :floats, :doubles then :float + else :integer end @endian = options.fetch(:endian,:little) case @format when :od @@ -162,16 +160,14 @@ if @encoding @base = BASES.fetch(options[:encoding]) @word_size = WORD_SIZES.fetch(options[:encoding]) end - case @encoding - when :hex_chars - @chars = CHARS.merge(ESCAPED_CHARS) - when :named_chars - @chars = CHARS.merge(NAMED_CHARS) - end + @chars = case @encoding + when :hex_chars then CHARS.merge(ESCAPED_CHARS) + when :named_chars then CHARS.merge(NAMED_CHARS) + end end # # Parses a hexdump. # @@ -350,14 +346,12 @@ # The parsed word. # # @api private # def parse_int(int) - if @chars - parse_char(int) - else - int.to_i(@base) + if @chars then parse_char(int) + else int.to_i(@base) end end # # Parses a float. @@ -381,13 +375,11 @@ # @return [Integer, Float] # The value of the word. # def parse_word(word) case @type - when :integer - parse_int(word) - when :float - parse_float(word) + when :integer then parse_int(word) + when :float then parse_float(word) end end # # Packs a segment back into bytes.