Class: FunWith::Files::Utils::TimestampFormat
- Inherits:
-
Object
- Object
- FunWith::Files::Utils::TimestampFormat
- Defined in:
- lib/fun_with/files/utils/timestamp_format.rb
Instance Method Summary collapse
- #format_time(t) ⇒ Object
-
#matches?(str, &block) ⇒ Boolean
does the given chunk look like a timestamp using this format? returns true or false.
-
#recognizer(regex) ⇒ Object
the timestamp identifies a chunk of the filename to be its kind of timestamp by checking it against a regular expression.
-
#strftime(s) ⇒ Object
The strftime format used to output the timestamp.
Instance Method Details
#format_time(t) ⇒ Object
19 20 21 |
# File 'lib/fun_with/files/utils/timestamp_format.rb', line 19 def format_time( t ) t.strftime( @strftime_format ) end |
#matches?(str, &block) ⇒ Boolean
does the given chunk look like a timestamp using this format? returns true or false.
25 26 27 |
# File 'lib/fun_with/files/utils/timestamp_format.rb', line 25 def matches?( str, &block ) @recognizer.match( str ) != nil end |
#recognizer(regex) ⇒ Object
the timestamp identifies a chunk of the filename to be its kind of timestamp by checking it against a regular expression.
8 9 10 11 |
# File 'lib/fun_with/files/utils/timestamp_format.rb', line 8 def recognizer( regex ) @recognizer = regex self end |
#strftime(s) ⇒ Object
The strftime format used to output the timestamp
14 15 16 17 |
# File 'lib/fun_with/files/utils/timestamp_format.rb', line 14 def strftime( s ) @strftime_format = s self end |