Class: MarshalParser::Formatters::Tokens::OneLine
- Inherits:
-
Object
- Object
- MarshalParser::Formatters::Tokens::OneLine
- Defined in:
- lib/marshal-parser/formatters/tokens/one_line.rb
Instance Method Summary collapse
-
#initialize(tokens, source_string, hex: nil) ⇒ OneLine
constructor
A new instance of OneLine.
- #string ⇒ Object
Constructor Details
#initialize(tokens, source_string, hex: nil) ⇒ OneLine
Returns a new instance of OneLine.
7 8 9 10 11 |
# File 'lib/marshal-parser/formatters/tokens/one_line.rb', line 7 def initialize(tokens, source_string, hex: nil) @tokens = tokens @source_string = source_string @hex = hex end |
Instance Method Details
#string ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/marshal-parser/formatters/tokens/one_line.rb', line 13 def string unless @hex @tokens.map do |token| string = @source_string[token.index, token.length] string =~ /[^[:print:]]/ ? string.dump : string end.join(" ") else @tokens.map do |token| string = @source_string[token.index, token.length] string = string.bytes.map { |b| "%02X" % b }.join(" ") end.join(" ") end end |