Class: ChatCorrect::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_correct/time.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#textObject (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

Returns:

  • (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