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.



80
81
82
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 80

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

#to_durationObject



88
89
90
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 88

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

#to_timezoneObject



84
85
86
# File 'lib/cocoa/sugarcube-nsdate/date_parser.rb', line 84

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