Module: IteratorOrSingleElement

Included in:
ArrayOrSingleElement, SetOrSingleElement
Defined in:
lib/ontomde-core/meta.rb

Overview

Helper methods to handle rdf ressources as object.

Constant Summary collapse

STRING_TO_BOOLEAN_HASH =
{ 'false' => false, 'true' => true}

Instance Method Summary collapse

Instance Method Details

#+(array) ⇒ Object



19
20
21
22
# File 'lib/ontomde-core/meta.rb', line 19

def +(array)
  return self if array.kind_of?(ArrayOrSingleElementEmpty)
  return super(array)
end

#isFalse?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ontomde-core/meta.rb', line 16

def isFalse?
  return !isTrue?
end

#isTrue?Boolean

Returns:

  • (Boolean)

Raises:



32
33
34
35
36
37
38
39
40
# File 'lib/ontomde-core/meta.rb', line 32

def isTrue?
  #return false if length==0
  return false if empty?
  raise Warning.new,"bad data for isTrue?(length=#{length}>1)" if length>1
  return false if self[0]=='false'
  return true  if self[0]=='true'
  raise Warning.new,"bad data for isTrue?(#{self[0]})" if length>1

end

#other_implem_isTrue?Boolean

Returns:

  • (Boolean)

Raises:



25
26
27
28
29
30
31
# File 'lib/ontomde-core/meta.rb', line 25

def other_implem_isTrue?
  return false if length==0
  raise Warning.new,"bad data for isTrue?(length=#{length}>1)" if length>1
  ret=STRING_TO_BOOLEAN_HASH[self[0]]
  return ret unless ret.nil?
  raise Warning.new,"bad data for isTrue?(#{self[0]})" if length>1
end

#to_sObject



7
8
9
10
11
12
13
14
15
# File 'lib/ontomde-core/meta.rb', line 7

def to_s
  r=''
  sep=''
  self.each{ |elt|
    r=r+sep+(elt.to_s)
    sep=' '
  }
  return r
end