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
17 18 19 |
# File 'lib/tty/table/orientation.rb', line 17 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name for the orientation
12 13 14 |
# File 'lib/tty/table/orientation.rb', line 12 def name @name end |
Class Method Details
.coerce(name) ⇒ Object
Coerce the name argument into an orientation
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tty/table/orientation.rb', line 26 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
51 52 53 |
# File 'lib/tty/table/orientation.rb', line 51 def horizontal? name == :horizontal end |
#vertical? ⇒ Boolean
Check if orientation is vertical
42 43 44 |
# File 'lib/tty/table/orientation.rb', line 42 def vertical? name == :vertical end |