Module: YolCommon

Defined in:
lib/yol_common.rb,
lib/yol_common/helper.rb,
lib/yol_common/version.rb,
lib/yol_common/validator.rb

Defined Under Namespace

Classes: Validator

Constant Summary collapse

VERSION =
"0.0.2"
MOBILE_REGEX =
Regexp.new('palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|webos|amoi|novarra|cdm|alcatel|pocket|iphone|mobileexplorer|mobile|zune')

Instance Method Summary collapse

Instance Method Details

#business_days_between(date1, date2) ⇒ Object

计算量日期间的工作日



25
26
27
28
29
30
31
32
33
# File 'lib/yol_common/helper.rb', line 25

def business_days_between(date1, date2)
  business_days = 0
  date = date2
  while date > date1
   business_days = business_days + 1 unless date.saturday? or date.sunday?
   date = date - 1.day
  end
  business_days
end

#duplicate_periods(periods) ⇒ Object

重复范围: 支持日期/数字等所有格式



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/yol_common/helper.rb', line 10

def duplicate_periods(periods)
  duplicate_periods = []
  periods.each do |a|
    a_index = periods.index(a)
    temp_periods = periods.clone
    temp_periods.delete_at(a_index)
    temp_periods.each do |b|
      result = a & b
      duplicate_periods << result if result
    end
  end
  duplicate_periods.uniq
end

#test(name) ⇒ Object



5
6
7
# File 'lib/yol_common/helper.rb', line 5

def test(name)
  name
end