Class: JsonCat::JsonPrettyPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/json_cat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ JsonPrettyPrinter

Returns a new instance of JsonPrettyPrinter.



19
20
21
22
# File 'lib/json_cat.rb', line 19

def initialize(**opts)
  self.count = 0
  opts.each { |k, v| instance_variable_set("@#{k}", v) }
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



18
19
20
# File 'lib/json_cat.rb', line 18

def count
  @count
end

#grepObject

Returns the value of attribute grep.



18
19
20
# File 'lib/json_cat.rb', line 18

def grep
  @grep
end

#omitObject

Returns the value of attribute omit.



18
19
20
# File 'lib/json_cat.rb', line 18

def omit
  @omit
end

#parseObject

Returns the value of attribute parse.



18
19
20
# File 'lib/json_cat.rb', line 18

def parse
  @parse
end

#sortObject

Returns the value of attribute sort.



18
19
20
# File 'lib/json_cat.rb', line 18

def sort
  @sort
end

#timestampObject

Returns the value of attribute timestamp.



18
19
20
# File 'lib/json_cat.rb', line 18

def timestamp
  @timestamp
end

Instance Method Details



24
25
26
27
28
29
30
31
# File 'lib/json_cat.rb', line 24

def print(line)
  x = json_parse(line)
  if x.is_a?(Hash)
    print_hash(x)
  else
    bow_print x
  end
end