Class: TerminalCalendar::Selection::Cell
- Inherits:
-
Object
- Object
- TerminalCalendar::Selection::Cell
- Defined in:
- lib/terminal_calendar/selection/cell.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#selected ⇒ Boolean
(also: #selected?)
readonly
Whether this cell is currently selected.
-
#selected_style ⇒ String
readonly
The rendered style of a cell that is selected.
-
#underlying_object ⇒ Object
readonly
The object that this cell wraps.
Class Method Summary collapse
-
.build(obj) ⇒ Cell
Builds a new cell object based on the given object.
Instance Method Summary collapse
-
#initialize(underlying_object, selected: false, selected_style: DEFAULT_SELECTED_STYLE) ⇒ Cell
constructor
A new instance of Cell.
-
#method_missing(method, *args, &block) ⇒ Object
Calls the missing method on the underlying object.
-
#null? ⇒ Boolean
Checks if the object is null.
-
#render ⇒ String
Renders the selected_style string if it is selected, otherwise returns the result of rendering the underlying object.
-
#respond_to_missing?(method, include_all) ⇒ Boolean
Checks if the underlying object responds to the missing method.
-
#toggle_selected! ⇒ Boolean
Toggles the selected state of the object.
Constructor Details
#initialize(underlying_object, selected: false, selected_style: DEFAULT_SELECTED_STYLE) ⇒ Cell
Returns a new instance of Cell.
22 23 24 25 26 |
# File 'lib/terminal_calendar/selection/cell.rb', line 22 def initialize(, selected: false, selected_style: DEFAULT_SELECTED_STYLE) @underlying_object = @selected = selected @selected_style = selected_style end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Calls the missing method on the underlying object.
60 61 62 |
# File 'lib/terminal_calendar/selection/cell.rb', line 60 def method_missing(method, *args, &block) .send(method, *args, &block) end |
Instance Attribute Details
#selected ⇒ Boolean (readonly) Also known as: selected?
Returns whether this cell is currently selected.
10 11 12 |
# File 'lib/terminal_calendar/selection/cell.rb', line 10 def selected @selected end |
#selected_style ⇒ String (readonly)
Returns the rendered style of a cell that is selected.
12 13 14 |
# File 'lib/terminal_calendar/selection/cell.rb', line 12 def selected_style @selected_style end |
#underlying_object ⇒ Object (readonly)
Returns the object that this cell wraps.
8 9 10 |
# File 'lib/terminal_calendar/selection/cell.rb', line 8 def @underlying_object end |
Class Method Details
Instance Method Details
#null? ⇒ Boolean
Checks if the object is null.
41 42 43 |
# File 'lib/terminal_calendar/selection/cell.rb', line 41 def null? false end |
#render ⇒ String
Renders the selected_style string if it is selected, otherwise returns the result of rendering the underlying object.
32 33 34 35 36 |
# File 'lib/terminal_calendar/selection/cell.rb', line 32 def render return .render unless selected? selected_style end |
#respond_to_missing?(method, include_all) ⇒ Boolean
Checks if the underlying object responds to the missing method.
69 70 71 |
# File 'lib/terminal_calendar/selection/cell.rb', line 69 def respond_to_missing?(method, include_all) .respond_to?(method) || super end |
#toggle_selected! ⇒ Boolean
Toggles the selected state of the object.
47 48 49 |
# File 'lib/terminal_calendar/selection/cell.rb', line 47 def toggle_selected! @selected = !@selected end |