class Circle::CLI::Model
Constants
- STATUS_COLORS
- TIME_FORMAT
Attributes
attributes[R]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/circle/cli/model.rb, line 16 def initialize(attributes = {}) @attributes = attributes end
Public Instance Methods
[](key)
click to toggle source
# File lib/circle/cli/model.rb, line 20 def [](key) @attributes[key.to_s] end
Private Instance Methods
color_for(value)
click to toggle source
# File lib/circle/cli/model.rb, line 31 def color_for(value) case value when *STATUS_COLORS[:green] then :green when *STATUS_COLORS[:yellow] then :yellow when *STATUS_COLORS[:red] then :red else :blue end end
format_time(value)
click to toggle source
# File lib/circle/cli/model.rb, line 26 def format_time(value) Time.parse(value).strftime(TIME_FORMAT) if value rescue ArgumentError end
truncate(str, len = 50)
click to toggle source
# File lib/circle/cli/model.rb, line 40 def truncate(str, len = 50) str && str.length > len ? "#{str[0..(len - 4)]}..." : str end