Class: Tempo::Views::ViewRecords::Query
- Inherits:
-
Object
- Object
- Tempo::Views::ViewRecords::Query
- Defined in:
- lib/tempo/views/view_records/base.rb
Overview
Query records are handled by the console formatter, returning results from a call to Readline
Instance Attribute Summary collapse
-
#match ⇒ Object
Returns the value of attribute match.
-
#query ⇒ Object
Returns the value of attribute query.
-
#response ⇒ Object
Returns the value of attribute response.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #format(&block) ⇒ Object
-
#initialize(query, options = {}) ⇒ Query
constructor
A new instance of Query.
- #positive_response? ⇒ Boolean
Constructor Details
#initialize(query, options = {}) ⇒ Query
Returns a new instance of Query.
54 55 56 57 58 59 |
# File 'lib/tempo/views/view_records/base.rb', line 54 def initialize(query, ={}) @query = query @type = "query" @match = .fetch(:match, /(y|Y)(es)?/) @response = Reporter.add_view_record self end |
Instance Attribute Details
#match ⇒ Object
Returns the value of attribute match.
52 53 54 |
# File 'lib/tempo/views/view_records/base.rb', line 52 def match @match end |
#query ⇒ Object
Returns the value of attribute query.
52 53 54 |
# File 'lib/tempo/views/view_records/base.rb', line 52 def query @query end |
#response ⇒ Object
Returns the value of attribute response.
52 53 54 |
# File 'lib/tempo/views/view_records/base.rb', line 52 def response @response end |
#type ⇒ Object
Returns the value of attribute type.
52 53 54 |
# File 'lib/tempo/views/view_records/base.rb', line 52 def type @type end |
Instance Method Details
#format(&block) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/tempo/views/view_records/base.rb', line 65 def format(&block) # TODO: should we create an interactive default? using: # confirm = Readline.readline('> ', true).match(/(y|Y)(es)?/) block ||= lambda { |q| puts "#{q.query}"; Readline.readline('> ', true) } response = block.call self end |
#positive_response? ⇒ Boolean
61 62 63 |
# File 'lib/tempo/views/view_records/base.rb', line 61 def positive_response? true if @response.match(@match) end |