Class: Tweetwine::IO

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

Constant Summary collapse

COLOR_CODES =
{
  :cyan     => 36,
  :green    => 32,
  :magenta  => 35,
  :yellow   => 33
}
HASHTAG_REGEX =
/#[\w-]+/
USERNAME_REGEX =
/@\w+/

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ IO

Returns a new instance of IO.



15
16
17
18
19
# File 'lib/tweetwine/io.rb', line 15

def initialize(options)
  @input = options[:input] || $stdin
  @output = options[:output] || $stdout
  @colorize = options[:colorize] || false
end

Instance Method Details

#confirm(msg) ⇒ Object



34
35
36
37
38
# File 'lib/tweetwine/io.rb', line 34

def confirm(msg)
  @output.print "#{msg} [yN] "
  confirmation = @input.gets.strip
  confirmation.downcase[0,1] == "y"
end

#info(msg) ⇒ Object



26
27
28
# File 'lib/tweetwine/io.rb', line 26

def info(msg)
  @output.puts(msg)
end

#prompt(prompt) ⇒ Object



21
22
23
24
# File 'lib/tweetwine/io.rb', line 21

def prompt(prompt)
  @output.print "#{prompt}: "
  @input.gets.strip!
end

#show_record(record) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/tweetwine/io.rb', line 48

def show_record(record)
  if record[:status]
    show_record_as_user_with_status(record)
  else
    show_record_as_user(record)
  end
end

#show_status_preview(status) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/tweetwine/io.rb', line 40

def show_status_preview(status)
  @output.puts <<-END

#{format_status(status)}

  END
end

#warn(msg) ⇒ Object



30
31
32
# File 'lib/tweetwine/io.rb', line 30

def warn(msg)
  @output.puts "Warning: #{msg}"
end