Class: Rumai::Barlet

Inherits:
Node show all
Defined in:
lib/rumai/wm.rb

Overview

Subdivision of the bar---the thing that spans the width of the screen---useful for displaying information and system controls.

Constant Summary

COLORS_REGEXP =
/^\S+ \S+ \S+/

Instance Attribute Summary (collapse)

Attributes inherited from Node

path

Instance Method Summary (collapse)

Methods inherited from Node

#[], #children, #clear, #create, #directory?, #each, #each_line, #entries, #exist?, #method_missing, #open, #parent, #read, #remove, #stat, #write

Constructor Details

- (Barlet) initialize(file_name, side)

A new instance of Barlet



1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
# File 'lib/rumai/wm.rb', line 1132

def initialize file_name, side
  prefix =
    case @side = side
    when :left then '/lbar'
    when :right then '/rbar'
    else raise ArgumentError, side
    end

  super "#{prefix}/#{file_name}"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rumai::Node

Instance Attribute Details

- (Object) side (readonly)

Returns the value of attribute side



1130
1131
1132
# File 'lib/rumai/wm.rb', line 1130

def side
  @side
end

Instance Method Details

- (Object) colors



1152
1153
1154
1155
1156
1157
# File 'lib/rumai/wm.rb', line 1152

def colors
  case read
  when /^colors (.*)$/ then $1
  when COLORS_REGEXP then $&
  end
end

- (Object) colors=(colors)



1176
1177
1178
1179
1180
1181
1182
# File 'lib/rumai/wm.rb', line 1176

def colors= colors
  if SPLIT_FILE_FORMAT
    write "colors #{colors}"
  else
    write "#{colors} #{label}"
  end
end

- (Object) label



1145
1146
1147
1148
1149
1150
# File 'lib/rumai/wm.rb', line 1145

def label
  case read
  when /^label (.*)$/ then $1
  when /#{COLORS_REGEXP} (.*)$/o then $1
  end
end

- (Object) label=(label)



1168
1169
1170
1171
1172
1173
1174
# File 'lib/rumai/wm.rb', line 1168

def label= label
  if SPLIT_FILE_FORMAT
    write "label #{label}"
  else
    write "#{colors} #{label}"
  end
end