Module: Ldpath::Functions

Included in:
Program
Defined in:
lib/ldpath/functions.rb

Instance Method Summary collapse

Instance Method Details

#concat(uri, context, *args) ⇒ Object



3
4
5
# File 'lib/ldpath/functions.rb', line 3

def concat uri, context, *args
  args.join
end

#contains(uri, context, str, substr) ⇒ Object



124
125
126
# File 'lib/ldpath/functions.rb', line 124

def contains uri, context, str, substr
  Array(str).map { |x| x.include? substr }
end

#earliest(uri, context, *args) ⇒ Object

dates



53
54
55
# File 'lib/ldpath/functions.rb', line 53

def earliest uri, context, *args
  args.flatten.min
end

#endsWith(uri, context, str, suffix) ⇒ Object



133
134
135
136
# File 'lib/ldpath/functions.rb', line 133

def endsWith uri, context, str, suffix
  
  Array(str).map { |x| x.end_with? suffix }
end

#eq(uri, context, *args) ⇒ Object



15
16
17
# File 'lib/ldpath/functions.rb', line 15

def eq uri, context, *args
  
end

#equals(uri, context, str, other) ⇒ Object



116
117
118
# File 'lib/ldpath/functions.rb', line 116

def equals uri, context, str, other
  Array(str).map { |x| x == other }
end

#equalsIgnoreCase(uri, context, str, other) ⇒ Object



120
121
122
# File 'lib/ldpath/functions.rb', line 120

def equalsIgnoreCase uri, context, str, other
  Array(str).map { |x| x.downcase == other.downcase }
end

#first(uri, context, *args) ⇒ Object



7
8
9
# File 'lib/ldpath/functions.rb', line 7

def first uri, context, *args
  args.flatten.compact.first
end

#flatten(uri, context, *args) ⇒ Object

collections



40
41
42
# File 'lib/ldpath/functions.rb', line 40

def flatten uri, context, *args
  
end

#ge(uri, context, *args) ⇒ Object



35
36
37
# File 'lib/ldpath/functions.rb', line 35

def ge uri, context, *args
  
end

#get(uri, context, *args) ⇒ Object



44
45
# File 'lib/ldpath/functions.rb', line 44

def get uri, context, *args
end

#gt(uri, context, *args) ⇒ Object



31
32
33
# File 'lib/ldpath/functions.rb', line 31

def gt uri, context, *args
  
end

#isEmpty(uri, context, str) ⇒ Object



138
139
140
141
# File 'lib/ldpath/functions.rb', line 138

def isEmpty uri, context, str
  
  Array(str).map(&:empty?)
end

#last(uri, context, *args) ⇒ Object



11
12
13
# File 'lib/ldpath/functions.rb', line 11

def last uri, context, *args
  args.flatten.compact.last
end

#latest(uri, context, *args) ⇒ Object



57
58
59
# File 'lib/ldpath/functions.rb', line 57

def latest uri, context, *args
  args.flatten.max
end

#le(uri, context, *args) ⇒ Object



27
28
29
# File 'lib/ldpath/functions.rb', line 27

def le uri, context, *args
  
end

#lt(uri, context, *args) ⇒ Object



23
24
25
# File 'lib/ldpath/functions.rb', line 23

def lt uri, context, *args
  
end

#max(uri, context, *args) ⇒ Object



67
68
69
# File 'lib/ldpath/functions.rb', line 67

def max uri, context, *args
  args.flatten.max
end

#min(uri, context, *args) ⇒ Object

math



63
64
65
# File 'lib/ldpath/functions.rb', line 63

def min uri, context, *args
  args.flatten.min
end

#ne(uri, context, *args) ⇒ Object



19
20
21
# File 'lib/ldpath/functions.rb', line 19

def ne uri, context, *args
  
end

#replace(uri, context, str, pattern, replacement) ⇒ Object

text



85
86
87
88
89
90
# File 'lib/ldpath/functions.rb', line 85

def replace uri, context, str, pattern, replacement
  regex = Regexp.parse(pattern)
  Array(str).map do |x|
    x.gsub(regex, replacement)
  end
end

#round(uri, context, *args) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/ldpath/functions.rb', line 71

def round uri, context, *args
  args.map do |n| 
    Array(n).map do |i|
      i.respond_to? :round ? i.round : i
    end
  end
end

#startsWith(uri, context, str, suffix) ⇒ Object



128
129
130
131
# File 'lib/ldpath/functions.rb', line 128

def startsWith uri, context, str, suffix
  
  Array(str).map { |x| x.start_with? suffix }
end

#strJoin(uri, context, str, sep = "", prefix = "", suffix = "") ⇒ Object



112
113
114
# File 'lib/ldpath/functions.rb', line 112

def strJoin uri, context, str, sep = "", prefix = "", suffix = ""
  prefix + Array(str).join(sep) + suffix
end

#strLeft(uri, context, str, left) ⇒ Object



100
101
102
# File 'lib/ldpath/functions.rb', line 100

def strLeft uri, context, str, left
  Array(str).map { |x| x[0..left.to_i] }
end

#strlen(uri, context, str) ⇒ Object



92
93
94
# File 'lib/ldpath/functions.rb', line 92

def strlen uri, context, str
  Array(str).map { |x| x.length }
end

#strRight(uri, context, str, right) ⇒ Object



104
105
106
# File 'lib/ldpath/functions.rb', line 104

def strRight uri, context, str, right
  Array(str).map { |x| x[right.to_i..x.length] }
end

#subList(uri, context, *args) ⇒ Object



47
48
49
# File 'lib/ldpath/functions.rb', line 47

def subList uri, context, *args
  
end

#substr(uri, context, str, left, right) ⇒ Object



108
109
110
# File 'lib/ldpath/functions.rb', line 108

def substr uri, context, str, left, right
  Array(str).map { |x| x[left.to_i..right.to_i] }
end

#sum(uri, context, *args) ⇒ Object



79
80
81
# File 'lib/ldpath/functions.rb', line 79

def sum uri, context, *args
  args.inject(0) { |sum, n| sum + n }
end

#wc(uri, context, str) ⇒ Object



96
97
98
# File 'lib/ldpath/functions.rb', line 96

def wc uri, context, str
  Array(str).map { |x| x.split.length }
end