Module: Bluecap

Extended by:
Bluecap
Included in:
Bluecap
Defined in:
lib/bluecap.rb,
lib/bluecap/keys.rb,
lib/bluecap/cohort.rb,
lib/bluecap/server.rb,
lib/bluecap/message.rb,
lib/bluecap/engagement.rb,
lib/bluecap/handlers/event.rb,
lib/bluecap/handlers/report.rb,
lib/bluecap/handlers/identify.rb,
lib/bluecap/handlers/attributes.rb,
lib/bluecap/handlers/null_handler.rb

Defined Under Namespace

Modules: Keys, Server Classes: Attributes, Cohort, Engagement, Event, Identify, Message, NullHandler, Report

Instance Method Summary collapse

Instance Method Details

#hostObject

Returns the String host to bind to.



50
51
52
53
54
# File 'lib/bluecap.rb', line 50

def host
  return @host if @host
  self.host = '0.0.0.0'
  self.host
end

#host=(host) ⇒ Object

Set the host to bind to.

Returns nothing.



45
46
47
# File 'lib/bluecap.rb', line 45

def host=(host)
  @host = host
end

#log(message) ⇒ Object

Log a message to STDOUT.

Returns nothing.



73
74
75
76
# File 'lib/bluecap.rb', line 73

def log(message)
  time = Time.now.strftime('%Y-%m-%d %H:%M:%S')
  puts "#{time} - #{message}"
end

#portObject

Returns the Integer port to bind to.



64
65
66
67
68
# File 'lib/bluecap.rb', line 64

def port
  return @port if @port
  self.port = 6088
  self.port
end

#port=(port) ⇒ Object

Set the port to bind to.

Returns nothing.



59
60
61
# File 'lib/bluecap.rb', line 59

def port=(port)
  @port = port
end

#redisObject

Returns the Redis client, creating a new client if one does not already exist.



36
37
38
39
40
# File 'lib/bluecap.rb', line 36

def redis
  return @redis if @redis
  self.redis = 'localhost:6379'
  self.redis
end

#redis=(server) ⇒ Object

Connect to Redis and store the resulting client.

server - A String of conncetion details in host:port format.

Examples

redis = 'localhost:6379'

Returns nothing.



29
30
31
32
# File 'lib/bluecap.rb', line 29

def redis=(server)
  host, port, database = server.split(':')
  @redis = Redis.new(host: host, port: port, database: database)
end