Class: ChatCorrect::Time
- Inherits:
-
Object
- Object
- ChatCorrect::Time
- Defined in:
- lib/chat_correct/time.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text:) ⇒ Time
constructor
A new instance of Time.
- #is_time? ⇒ Boolean
Constructor Details
#initialize(text:) ⇒ Time
Returns a new instance of Time.
4 5 6 |
# File 'lib/chat_correct/time.rb', line 4 def initialize(text:) @text = text end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/chat_correct/time.rb', line 3 def text @text end |
Instance Method Details
#is_time? ⇒ Boolean
8 9 10 11 12 |
# File 'lib/chat_correct/time.rb', line 8 def is_time? return false if !text.include?(':') || text.to_s.partition(':').last[0].nil? || text.to_s.partition(':').first[-1].nil? text.to_s.partition(':').last[0].gsub(/\A\d+/, '').eql?('') && text.to_s.partition(':').first[-1].gsub(/\A\d+/, '').eql?('') end |