Class: RDF::Literal::NonPositiveInteger

Inherits:
Integer
  • Object
show all
Defined in:
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

Instance Method Summary collapse

Instance Method Details

#-@RDF::Literal::Numeric

Returns self negated.

Returns:

  • (RDF::Literal::Numeric)


17
18
19
20
21
22
# File 'lib/rdf/xsd/integer.rb', line 17

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

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rdf/xsd/integer.rb', line 24

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