Class: Swat::StatBox
- Inherits:
-
Object
- Object
- Swat::StatBox
- Defined in:
- lib/stat_box.rb
Instance Attribute Summary collapse
-
#meta_data ⇒ Object
Returns the value of attribute meta_data.
-
#vbox_container ⇒ Object
Returns the value of attribute vbox_container.
Instance Method Summary collapse
- #hide_all ⇒ Object
-
#initialize(meta_data) ⇒ StatBox
constructor
A new instance of StatBox.
- #set_lastweek_label ⇒ Object
- #set_today_label(p_meta_data = nil) ⇒ Object
- #set_yesterday_label ⇒ Object
- #show_all ⇒ Object
- #update_today_label(p_meta_data = nil) ⇒ Object
Constructor Details
#initialize(meta_data) ⇒ StatBox
Returns a new instance of StatBox.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/stat_box.rb', line 4 def initialize() @meta_data = @vbox_container = Gtk::VBox.new stat_label = Gtk::Label.new stat_label.xalign = 0.02 stat_label.set_markup("<span underline='double' weight='bold' style='oblique'> Stats </span>\n") @vbox_container.pack_start(stat_label,false,false) set_today_label @vbox_container.pack_start(@today_label,false,false) set_yesterday_label @vbox_container.pack_start(@yesterday_label,false,false) set_lastweek_label @vbox_container.pack_start(@lastweek_label,false,false) end |
Instance Attribute Details
#meta_data ⇒ Object
Returns the value of attribute meta_data.
3 4 5 |
# File 'lib/stat_box.rb', line 3 def @meta_data end |
#vbox_container ⇒ Object
Returns the value of attribute vbox_container.
3 4 5 |
# File 'lib/stat_box.rb', line 3 def vbox_container @vbox_container end |
Instance Method Details
#hide_all ⇒ Object
50 51 52 |
# File 'lib/stat_box.rb', line 50 def hide_all @vbox_container.hide_all end |
#set_lastweek_label ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/stat_box.rb', line 68 def set_lastweek_label lastweek_heading = Gtk::Label.new lastweek_heading.xalign = 0.02 lastweek_heading.set_markup("<span foreground='#6d0835' style='oblique'> Lastweek </span>") @vbox_container.pack_start(lastweek_heading,false,false) @lastweek_label = Gtk::Label.new @lastweek_label.xalign = 0 lastweek_str = <<-EOD <small> Done : <span foreground='#206d08'> #{@meta_data.tasks_done_lastweek} </span>, Added : <span foreground='red'> #{@meta_data.tasks_added_lastweek}</span> </small> EOD @lastweek_label.set_markup(lastweek_str) end |
#set_today_label(p_meta_data = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stat_box.rb', line 23 def set_today_label( = nil) @meta_data = if today_heading = Gtk::Label.new today_heading.xalign = 0.02 today_heading.set_markup("<span foreground='#6d0835' style='oblique' > Today </span>") @vbox_container.pack_start(today_heading,false,false) @today_label = Gtk::Label.new @today_label.xalign = 0 today_str = <<-EOD <small> Done : <span foreground='#206d08'>#{@meta_data.tasks_done_today}</span>, Added : <span foreground='red'>#{@meta_data.tasks_added_today}</span> </small> EOD @today_label.set_markup(today_str) end |
#set_yesterday_label ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/stat_box.rb', line 54 def set_yesterday_label yesterday_heading = Gtk::Label.new yesterday_heading.xalign = 0.02 yesterday_heading.set_markup("<span foreground='#6d0835' style='oblique'> Yesterday </span>") @vbox_container.pack_start(yesterday_heading,false,false) @yesterday_label = Gtk::Label.new @yesterday_label.xalign = 0 yesterday_str = <<-EOD <small> Done : <span foreground='#206d08'>#{@meta_data.tasks_done_yesterday}</span>, Added : <span foreground='red'>#{@meta_data.tasks_added_yesterday}</span> </small> EOD @yesterday_label.set_markup(yesterday_str) end |
#show_all ⇒ Object
46 47 48 |
# File 'lib/stat_box.rb', line 46 def show_all @vbox_container.show_all end |
#update_today_label(p_meta_data = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/stat_box.rb', line 38 def update_today_label( = nil) @meta_data = if today_str = <<-EOD <small> Done : <span foreground='#206d08'>#{@meta_data.tasks_done_today}</span>, Added : <span foreground='red'>#{@meta_data.tasks_added_today}</span> </small> EOD @today_label.set_markup(today_str) end |