class WeatherCard::SevenLines

Attributes

day[RW]

1 ——————————— 2 | dayText short_detail | 3 | H:xxx L:xxx Current:xxx | 4 | UV:xxxxxxx sunrise:xxxxxxx | 5 | wind:xxxxxxxx sunset:xxxxxxx | 6 | humidity:xxxx precip:xxxx | 7 | panel1 low:xxx | 8 | panel1 precip:xxx | 9 ———————————

Public Class Methods

all() click to toggle source
# File lib/weathercard.rb, line 151
def self.all
    @@all
end
horizontal() click to toggle source
# File lib/weathercard.rb, line 143
def self.horizontal
    @@horizontal
end
length() click to toggle source

:day, :panel_1_name, :current_temp, :panel_1_temp, :panel_2_temp, :short_detail, panel_1_short_detail, :panel_2_short_detail :precipitation, :panel_1_precip, :panel_2_precip, :max, :min, :wind_direction, :wind_magnitude, :wind_units, :long_detail, :humidity, :uv_index, :sunrise, :sunset

# File lib/weathercard.rb, line 139
def self.length
    @@length
end
new(day) click to toggle source
# File lib/weathercard.rb, line 155
def initialize(day)
    self.day = day
end
vertical() click to toggle source
# File lib/weathercard.rb, line 147
def self.vertical
    @@vertical
end

Public Instance Methods

detail() click to toggle source
# File lib/weathercard.rb, line 227
def detail
    words = day.long_detail.split(' ')
    while words.length > 0 do
        new_string = ''
        while new_string.length + words[0].length < @@length do
            new_string += words.shift
            new_string += ' '
            break if words == []
        end
        spaces = return_spaces(new_string.length)
        new_string = "#{new_string.colorize(:light_yellow)}#{spaces}"                
        puts line_intermediate(new_string)
    end
end
display() click to toggle source
# File lib/weathercard.rb, line 216
def display
    puts line1
    puts line2
    puts line3
    puts line4
    puts line5
    puts line6
    detail
    puts line9
end
line1() click to toggle source
# File lib/weathercard.rb, line 159
def line1
    line_end
end
line2() click to toggle source
# File lib/weathercard.rb, line 163
def line2
    str_length = day.day.length + day.short_detail.length
    spaces = return_spaces(str_length)
    str = "#{day.day}#{spaces}#{day.short_detail}"
    line_intermediate(str)
end
line3() click to toggle source
# File lib/weathercard.rb, line 170
def line3
    str_length = day.max.length + day.min.length + day.current_temp.length + 16
    spaces = return_spaces(str_length)
    str = "H:#{day.max.colorize(:light_red)}  L:#{day.min.colorize(:light_blue)}#{spaces}Currently:#{day.current_temp}"
    line_intermediate(str)
end
line4() click to toggle source
# File lib/weathercard.rb, line 177
def line4
    str_length = day.uv_index.length + day.sunrise.length + 11
    spaces = return_spaces(str_length)
    str = "UV:#{day.uv_index}#{spaces}feels like:#{day.feels_like}"
    line_intermediate(str)
end
line5() click to toggle source
# File lib/weathercard.rb, line 184
def line5
    str_length = day.wind_magnitude.length + day.wind_direction.length + day.wind_units.length + day.sunset.length + 13
    spaces = return_spaces(str_length)
    str = "wind:#{day.wind_direction}#{day.wind_magnitude}#{day.wind_units}#{spaces}sunrise #{day.sunrise}"
    line_intermediate(str)
end
line6() click to toggle source
# File lib/weathercard.rb, line 191
def line6
    str_length = day.humidity.length + day.sunset.length + 16
    spaces = return_spaces(str_length)
    str = "humidity:#{day.humidity}#{spaces}sunset #{day.sunset}"
    line_intermediate(str)
end
line7() click to toggle source
# File lib/weathercard.rb, line 198
def line7
    str_length = day.panel1_name.length + day.panel1_temp.length + 5
    spaces = return_spaces(str_length)
    str = "#{day.panel1_name} low:#{day.panel1_temp}#{spaces}"
    line_intermediate(str)
end
line8() click to toggle source
# File lib/weathercard.rb, line 205
def line8
    str_length = day.panel1_name.length + day.panel1_precip.length + 8
    spaces = return_spaces(str_length)
    str = "#{day.panel1_name} precip:#{day.panel1_precip}#{spaces}"
    line_intermediuate(str)
end
line9() click to toggle source
# File lib/weathercard.rb, line 212
def line9
    line1
end