Class: Vedeu::Borders::Border
- Inherits:
-
Object
- Object
- Vedeu::Borders::Border
show all
- Extended by:
- Forwardable
- Includes:
- Common, Model, Presentation
- Defined in:
- lib/vedeu/borders/border.rb
Overview
Provides the mechanism to decorate an interface with a border on all edges, or specific edges. The characters which are used for the border parts (e.g. the corners, verticals and horizontals) can be customised as can the colours and styles.
Instance Attribute Summary collapse
Attributes included from Model
#repository
Instance Method Summary
collapse
#render_colour, #render_position, #render_style, #to_s
#style, #style=
#background, #background=, #colour, #colour=, #foreground, #foreground=
Methods included from Model
#deputy, #dsl_class, included, #store
Methods included from Common
#demodulize, #present?, #snake_case
Constructor Details
Returns a new instance of Vedeu::Borders::Border.
129
130
131
132
133
134
135
|
# File 'lib/vedeu/borders/border.rb', line 129
def initialize(attributes = {})
@attributes = defaults.merge!(attributes)
@attributes.each do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Instance Attribute Details
#attributes ⇒ Hash
32
33
34
|
# File 'lib/vedeu/borders/border.rb', line 32
def attributes
@attributes
end
|
#bottom_left ⇒ String
36
37
38
|
# File 'lib/vedeu/borders/border.rb', line 36
def bottom_left
@bottom_left
end
|
#bottom_right ⇒ String
40
41
42
|
# File 'lib/vedeu/borders/border.rb', line 40
def bottom_right
@bottom_right
end
|
#caption ⇒ String
68
69
70
|
# File 'lib/vedeu/borders/border.rb', line 68
def caption
@caption
end
|
#enabled ⇒ Boolean
Also known as:
enabled?
92
93
94
|
# File 'lib/vedeu/borders/border.rb', line 92
def enabled
@enabled
end
|
#horizontal ⇒ String
44
45
46
|
# File 'lib/vedeu/borders/border.rb', line 44
def horizontal
@horizontal
end
|
#name ⇒ String
88
89
90
|
# File 'lib/vedeu/borders/border.rb', line 88
def name
@name
end
|
#show_bottom ⇒ Boolean
Also known as:
bottom?
48
49
50
|
# File 'lib/vedeu/borders/border.rb', line 48
def show_bottom
@show_bottom
end
|
#show_left ⇒ Boolean
Also known as:
left?
53
54
55
|
# File 'lib/vedeu/borders/border.rb', line 53
def show_left
@show_left
end
|
#show_right ⇒ Boolean
Also known as:
right?
58
59
60
|
# File 'lib/vedeu/borders/border.rb', line 58
def show_right
@show_right
end
|
#show_top ⇒ Boolean
Also known as:
top?
63
64
65
|
# File 'lib/vedeu/borders/border.rb', line 63
def show_top
@show_top
end
|
#title ⇒ String
72
73
74
|
# File 'lib/vedeu/borders/border.rb', line 72
def title
@title
end
|
#top_left ⇒ String
76
77
78
|
# File 'lib/vedeu/borders/border.rb', line 76
def top_left
@top_left
end
|
#top_right ⇒ String
80
81
82
|
# File 'lib/vedeu/borders/border.rb', line 80
def top_right
@top_right
end
|
#vertical ⇒ String
84
85
86
|
# File 'lib/vedeu/borders/border.rb', line 84
def vertical
@vertical
end
|
Instance Method Details
#bx ⇒ Fixnum
138
139
140
|
# File 'lib/vedeu/borders/border.rb', line 138
def bx
(enabled? && left?) ? x + 1 : x
end
|
#bxn ⇒ Fixnum
143
144
145
|
# File 'lib/vedeu/borders/border.rb', line 143
def bxn
(enabled? && right?) ? xn - 1 : xn
end
|
#by ⇒ Fixnum
148
149
150
|
# File 'lib/vedeu/borders/border.rb', line 148
def by
(enabled? && top?) ? y + 1 : y
end
|
#byn ⇒ Fixnum
153
154
155
|
# File 'lib/vedeu/borders/border.rb', line 153
def byn
(enabled? && bottom?) ? yn - 1 : yn
end
|
#defaults ⇒ Hash
The default values for a new instance of this class.
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/vedeu/borders/border.rb', line 195
def defaults
{
bottom_left: Vedeu::EscapeSequences::Borders.bottom_left,
bottom_right: Vedeu::EscapeSequences::Borders.bottom_right,
caption: '',
client: nil,
colour: nil,
enabled: false,
horizontal: Vedeu::EscapeSequences::Borders.horizontal,
name: '',
repository: Vedeu.borders,
show_bottom: true,
show_left: true,
show_right: true,
show_top: true,
style: nil,
title: '',
top_left: Vedeu::EscapeSequences::Borders.top_left,
top_right: Vedeu::EscapeSequences::Borders.top_right,
vertical: Vedeu::EscapeSequences::Borders.vertical,
}
end
|
181
182
183
|
# File 'lib/vedeu/borders/border.rb', line 181
def geometry
Vedeu.geometries.by_name(name)
end
|
#height ⇒ Fixnum
Returns the height of the interface determined by whether a top, bottom, both or neither borders are shown.
169
170
171
|
# File 'lib/vedeu/borders/border.rb', line 169
def height
(by..byn).size
end
|
186
187
188
|
# File 'lib/vedeu/borders/border.rb', line 186
def interface
@interface ||= Vedeu.interfaces.by_name(name)
end
|
174
175
176
|
# File 'lib/vedeu/borders/border.rb', line 174
def render
Vedeu::Borders::Render.with(self)
end
|
#width ⇒ Fixnum
Returns the width of the interface determined by whether a left, right, both or neither borders are shown.
161
162
163
|
# File 'lib/vedeu/borders/border.rb', line 161
def width
(bx..bxn).size
end
|