Module: OpenWFE::Extras
- Defined in:
- lib/openwfe/extras/util/csvtable.rb,
lib/openwfe/extras/misc/activityfeed.rb,
lib/openwfe/extras/expool/dbexpstorage.rb,
lib/openwfe/extras/expool/dberrorjournal.rb,
lib/openwfe/extras/listeners/sqslisteners.rb,
lib/openwfe/extras/engine/db_persisted_engine.rb,
lib/openwfe/extras/participants/csvparticipants.rb,
lib/openwfe/extras/participants/sqsparticipants.rb,
lib/openwfe/extras/participants/activeparticipants.rb,
lib/openwfe/extras/participants/twitterparticipants.rb,
lib/openwfe/extras/participants/atompub_participants.rb,
lib/openwfe/extras/participants/atomfeed_participants.rb
Defined Under Namespace
Classes: ActiveParticipant, ActiveStoreParticipant, ActivityFeedService, AtomFeedParticipant, AtomPubParticipant, BlogParticipant, CachedDbPersistedEngine, CsvParticipant, CsvTable, DbErrorJournal, DbExpressionStorage, DbPersistedEngine, Entry, Expression, ExpressionTables, Field, InFlowWorkItem, ProcessError, ProcessErrorTables, SqsListener, SqsParticipant, ThreadedDbExpressionStorage, TwitterParticipant, Workitem, WorkitemTables
Constant Summary collapse
- RUBY_NUMERIC_RANGE_REGEXP =
A regexp for checking if a string is a numeric Ruby range
Regexp.compile( "^\\d+(\\.\\d+)?\\.{2,3}\\d+(\\.\\d+)?$")
- RUBY_ALPHA_RANGE_REGEXP =
A regexp for checking if a string is an alpha Ruby range
Regexp.compile( "^([A-Za-z])(\\.{2,3})([A-Za-z])$")
- MUTEX =
Mutex.new
Instance Method Summary collapse
-
#to_ruby_range(s) ⇒ Object
If the string contains a Ruby range definition (ie something like “93.0..94.5” or “56..72”), it will return the Range instance.
Instance Method Details
#to_ruby_range(s) ⇒ Object
If the string contains a Ruby range definition (ie something like “93.0..94.5” or “56..72”), it will return the Range instance. Will return nil else.
The Ruby range returned (if any) will accept String or Numeric, ie (4..6).include?(“5”) will yield true.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/openwfe/extras/util/csvtable.rb', line 74 def to_ruby_range (s) range = if RUBY_NUMERIC_RANGE_REGEXP.match(s) eval s else m = RUBY_ALPHA_RANGE_REGEXP.match(s) if m eval "'#{m[1]}'#{m[2]}'#{m[3]}'" else nil end end class << range alias :old_include? :include? def include? (elt) elt = if first.is_a?(Numeric) Float(elt) else elt end old_include?(elt) end end if range range end |