Class: TTY::Table::Orientation
- Inherits:
-
Object
- Object
- TTY::Table::Orientation
- Defined in:
- lib/tty/table/orientation.rb,
lib/tty/table/orientation/vertical.rb,
lib/tty/table/orientation/horizontal.rb
Overview
A class representing table orientation
Direct Known Subclasses
Defined Under Namespace
Classes: Horizontal, Vertical
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name for the orientation.
Class Method Summary collapse
-
.coerce(name) ⇒ Object
Coerce the name argument into an orientation.
Instance Method Summary collapse
-
#horizontal? ⇒ Boolean
Check if orientation is horizontal.
-
#initialize(name) ⇒ Orientation
constructor
Initialize an Orientation.
-
#vertical? ⇒ Boolean
Check if orientation is vertical.
Constructor Details
#initialize(name) ⇒ Orientation
Initialize an Orientation
20 21 22 |
# File 'lib/tty/table/orientation.rb', line 20 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name for the orientation
15 16 17 |
# File 'lib/tty/table/orientation.rb', line 15 def name @name end |
Class Method Details
.coerce(name) ⇒ Object
Coerce the name argument into an orientation
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tty/table/orientation.rb', line 29 def self.coerce(name) case name.to_s when /h|horiz(ontal)?/i Horizontal.new :horizontal when /v|ert(ical)?/i Vertical.new :vertical else raise InvalidOrientationError, "orientation must be one of :horizontal, :vertical" end end |
Instance Method Details
#horizontal? ⇒ Boolean
Check if orientation is horizontal
55 56 57 |
# File 'lib/tty/table/orientation.rb', line 55 def horizontal? name == :horizontal end |
#vertical? ⇒ Boolean
Check if orientation is vertical
46 47 48 |
# File 'lib/tty/table/orientation.rb', line 46 def vertical? name == :vertical end |