Class: RDF::Literal::NonPositiveInteger

Inherits:
Integer show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-0489489cebb4/lib/rdf/xsd/integer.rb

Overview

nonPositiveInteger is derived from integer by setting the value of maxInclusive to be 0. This results in the standard mathematical concept of the non-positive integers. The value space of nonPositiveInteger is the infinite set .....,-2,-1,0. The base type of nonPositiveInteger is integer.

Direct Known Subclasses

NegativeInteger

Constant Summary collapse

DATATYPE =
RDF::XSD.nonPositiveInteger
GRAMMAR =
/^(?:[\+\-]?0)|(?:-\d+)$/.freeze

Constants inherited from RDF::Literal

FALSE, TRUE, ZERO

Instance Attribute Summary

Attributes inherited from RDF::Literal

#datatype, #language

Instance Method Summary collapse

Methods inherited from Integer

#abs, #canonicalize!, #even?, #initialize, #nonzero?, #odd?, #pred, #round, #succ, #to_bn, #to_s, #zero?

Methods inherited from Decimal

#abs, #canonicalize!, #ceil, #floor, #initialize, #nonzero?, #round, #to_s, #zero?

Methods inherited from Numeric

#*, #+, #+@, #-, #/, #<=>, #==, #abs, #ceil, #floor, #round, #to_d, #to_f, #to_i, #to_r

Methods inherited from RDF::Literal

#==, #canonicalize!, #compatible?, #comperable_datatype?, #eql?, #escape, #has_datatype?, #has_language?, #hash, #humanize, #initialize, #inspect, #literal?, #method_missing, #object, #plain?, #respond_to_missing?, #simple?, #squish, #squish!, #to_s, #validate!, #value, #value_hash

Methods included from Term

#<=>, #==, #aggregate?, #compatible?, #eql?, #escape, #evaluate, #ndvars, #term?, #to_base, #to_term, #vars

Methods included from SPARQL::Algebra::Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #validate!, #variable?

Methods included from Value

#anonymous?, #canonicalize, #canonicalize!, #constant?, #graph?, #inspect, #inspect!, #invalid?, #iri?, #list?, #literal?, #node?, #resource?, #start_with?, #statement?, #term?, #to_nquads, #to_ntriples, #to_rdf, #to_term, #type_error, #uri?, #validate!, #variable?

Constructor Details

This class inherits a constructor from RDF::Literal::Integer

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RDF::Literal

Instance Method Details

#-@RDF::Literal::Numeric

Returns self negated.



17
18
19
20
21
22
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-0489489cebb4/lib/rdf/xsd/integer.rb', line 17

def -@
  if object != 0
    # XXX Raise error?
  end
  super
end

#valid?Boolean

Returns:



24
25
26
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-xsd-0489489cebb4/lib/rdf/xsd/integer.rb', line 24

def valid?
  super && @object <= 0
end