Class: Roast::Main
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#message ⇒ Object
Returns the value of attribute message.
-
#password ⇒ Object
Returns the value of attribute password.
-
#room ⇒ Object
Returns the value of attribute room.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Main
constructor
A new instance of Main.
- #vocalize(message) ⇒ Object
Constructor Details
#initialize(options) ⇒ Main
Returns a new instance of Main.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/roast/main.rb', line 8 def initialize() @message = [:message] @config = YAML.load_file(ENV['HOME'] + '/roast.yml') room_config = @config[([:room] ? [:room].to_s : @config["default"])] @room = room_config['room'] @domain = room_config['domain'] @ssl = room_config['ssl'] @username = room_config['username'] @password = room_config['password'] @verbose = [:verbose] self end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def config @config end |
#domain ⇒ Object
Returns the value of attribute domain.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def domain @domain end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def @message end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def password @password end |
#room ⇒ Object
Returns the value of attribute room.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def room @room end |
#ssl ⇒ Object
Returns the value of attribute ssl.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def ssl @ssl end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def username @username end |
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/roast/main.rb', line 6 def verbose @verbose end |
Class Method Details
.run(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/roast/main.rb', line 21 def self.run(={}) opts = OptionParser.new do |opt| opt. = "Usage: roast [options] message" opt.separator "" opt.separator "Specific options:" opt.on("-r", "--room [room config]", "Room name from config") do |room| [:room] = room end opt.on("-v", "--verbose", "Be verbose during the posting of the message") do |verbose| [:verbose] = true end end opts.parse!(ARGV) roast = Roast::Main.new() roast.vocalize "Using #{roast.room} configuration ..." campfire = Campfire.new(roast.domain, :ssl => roast.ssl) roast.vocalize "Logging in..." campfire.login(roast.username, roast.password) roast.vocalize "Logged in!" room = campfire.find_room_by_name(roast.room) roast.vocalize "Joining #{room.name}..." roast.vocalize "Entered room #{room.name}" roast.vocalize "Saying message..." if ([:message]) room.paste([:message]) else room.speak([:message]) end roast.vocalize "Leaving room..." roast.vocalize "Done." end |
Instance Method Details
#vocalize(message) ⇒ Object
68 69 70 |
# File 'lib/roast/main.rb', line 68 def vocalize() STDOUT.puts if self.verbose end |