Class: String

Inherits:
Object show all
Defined in:
lib/ios/sugarcube-pipes/pipes.rb,
lib/cocoa/sugarcube-nsdate/date_parser.rb

Instance Method Summary collapse

Instance Method Details

#to_dateObject

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.



86
87
88
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 86

def to_date
  SugarCube::DateParser.parse_date(self)
end

#to_durationObject



94
95
96
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 94

def to_duration
  SugarCube::DateParser.parse_duration(self)
end

#to_timezoneObject



90
91
92
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 90

def to_timezone
  SugarCube::DateParser.parse_time_zone(self)
end

#|(filter) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/ios/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.to_s} class"
  end
end