Class: Dhall::Natural
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Expression
#&, #as_dhall, #cache_key, #call, #concat, decode, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #fusion, #merge, #normalize, #resolve, #shift, #slice, #substitute, #to_cbor, #to_proc, #|
Class Method Details
.as_dhall ⇒ Object
985
986
987
|
# File 'lib/dhall/ast.rb', line 985
def self.as_dhall
Builtins[:Natural]
end
|
Instance Method Details
#*(other) ⇒ Object
1002
1003
1004
1005
1006
1007
1008
1009
1010
|
# File 'lib/dhall/ast.rb', line 1002
def *(other)
other = other.as_dhall
return self if zero?
if other.is_a?(Natural)
with(value: value * other.value)
else
super
end
end
|
#+(other) ⇒ Object
993
994
995
996
997
998
999
1000
|
# File 'lib/dhall/ast.rb', line 993
def +(other)
other = other.as_dhall
if other.is_a?(Natural)
with(value: value + other.value)
else
super
end
end
|
#===(other) ⇒ Object
1036
1037
1038
|
# File 'lib/dhall/ast.rb', line 1036
def ===(other)
self == other || value === other
end
|
#as_json ⇒ Object
1040
1041
1042
|
# File 'lib/dhall/ast.rb', line 1040
def as_json
[15, value]
end
|
#coerce(other) ⇒ Object
989
990
991
|
# File 'lib/dhall/ast.rb', line 989
def coerce(other)
[other.as_dhall, self]
end
|
#even? ⇒ Boolean
1020
1021
1022
|
# File 'lib/dhall/ast.rb', line 1020
def even?
value.even?
end
|
#odd? ⇒ Boolean
1024
1025
1026
|
# File 'lib/dhall/ast.rb', line 1024
def odd?
value.odd?
end
|
#pred ⇒ Object
1032
1033
1034
|
# File 'lib/dhall/ast.rb', line 1032
def pred
with(value: [0, value - 1].max)
end
|
#to_i ⇒ Object
1012
1013
1014
|
# File 'lib/dhall/ast.rb', line 1012
def to_i
value
end
|
#to_s ⇒ Object
1016
1017
1018
|
# File 'lib/dhall/ast.rb', line 1016
def to_s
value.to_s
end
|
#zero? ⇒ Boolean
1028
1029
1030
|
# File 'lib/dhall/ast.rb', line 1028
def zero?
value.zero?
end
|