class Rrant::Output

Public: Outputs rant hash, or serialized rant with image to the STDOUT.

rant - Hash, rant to be outputed. show_images - Boolean, when set we output attached image also.

Public Class Methods

new(rant, show_images) click to toggle source
# File lib/rrant/output.rb, line 9
def initialize(rant, show_images)
  @rant = rant
  @show_images = show_images
end

Public Instance Methods

in() click to toggle source

Public: Returns rant as a hash.

# File lib/rrant/output.rb, line 15
def in
  @rant
end
out() click to toggle source

Public: Prints serialzied rant to the STDOUT.

# File lib/rrant/output.rb, line 20
def out
  puts_image
  puts @rant['text']
  puts footer
end

Private Instance Methods

build_address() click to toggle source
# File lib/rrant/output.rb, line 50
def build_address
  'https://www.devrant.io/'.tap do |url|
    url << "rants/#{@rant['id']}" if @rant['id']
  end
end
puts_image() click to toggle source

Wrapper around Catpix gem, prints image to terminal.

# File lib/rrant/output.rb, line 40
def puts_image
  return unless @show_images
  return unless @rant['image']

  Catpix.print_image(@rant['image'],
                     resolution: 'low',
                     limit_x: 0.4,
                     limit_y: 0.4)
end