Class: String
- Defined in:
- lib/sugarcube-pipes/pipes.rb,
lib/sugarcube-nsdate/date_parser.rb
Instance Method Summary collapse
-
#to_date ⇒ Object
Use NSDataDetector to parse a string containing a date or duration.
- #to_duration ⇒ Object
- #to_timezone ⇒ Object
- #|(filter) ⇒ Object
Instance Method Details
#to_date ⇒ Object
Use NSDataDetector to parse a string containing a date or duration. These can be of the form:
"tomorrow at 7:30 PM" "11.23.2013" "from 7:30 to 10:00 AM"
etc.
55 56 57 |
# File 'lib/sugarcube-nsdate/date_parser.rb', line 55 def to_date SugarCube::DateParser.parse_date(self) end |
#to_duration ⇒ Object
63 64 65 |
# File 'lib/sugarcube-nsdate/date_parser.rb', line 63 def to_duration SugarCube::DateParser.parse_duration(self) end |
#to_timezone ⇒ Object
59 60 61 |
# File 'lib/sugarcube-nsdate/date_parser.rb', line 59 def to_timezone SugarCube::DateParser.parse_time_zone(self) end |
#|(filter) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sugarcube-pipes/pipes.rb', line 67 def |(filter) if Regexp === filter match = filter.match(self) match && match[0] elsif String === filter self.index(filter) && filter else raise "The `|` operator is not supported for the #{filter.is_a?(Class) ? filter.name : filter.class.name} class" end end |