Redland RDF Application Framework - Ruby RDoc - Class: Redland::Literal

Go to Redland Home - Language Bindings Home - Ruby API Home

Class | Redland::Literal
In: | rdf/redland/node.rb
Parent: | Node

A literal node

### Methods

from_node from_xml new

### Included Modules

Redland

### Attributes

language | [R] | the language of the literal
value | [R] | the string value of the literal

### Public Class methods

from_node(node)

create a literal from another Node

[Source]

    # File rdf/redland/node.rb, line 246
        def Literal.from_node(node)
          lang = Redland.librdf_node_get_literal_value_language(node) if Redland.librdf_node_get_literal_value_language(node)
          str = Redland.librdf_node_get_literal_value(node)
          hash_uri = Redland.librdf_node_get_literal_value_datatype_uri(node)
          hash_uri = Uri.new(Redland.librdf_uri_to_string(hash_uri)) if hash_uri
          return Literal.new(str,lang,hash_uri)
        end

from_xml(str,lang=nil)

create a literal from and xml string

     literal = Literal.from_xml('<em>This is emphasized</em>')

[Source]

    # File rdf/redland/node.rb, line 256
        def Literal.from_xml(str,lang=nil)
          return Literal.new(str,lang,nil,true)
        end

new(str,lang=nil,uri=nil,is_xml=false)

create a new Literal node

     literal = Literal.new('Dominic')
     label = Literal.new('Name','en')

[Source]

    # File rdf/redland/node.rb, line 231
        def initialize(str,lang=nil,uri=nil,is_xml=false)
          @value = str
          @language = lang
          is_xml = is_xml==true ? 1 : 0
          if uri
            @node = Redland.librdf_new_node_from_typed_literal($world.world,value,lang,uri.uri)
          else
            @node = Redland.librdf_new_node_from_literal($world.world,value,lang,is_xml)
          end

          raise RedlandError.new("Node construction failed") if not @node
          ObjectSpace.define_finalizer(self,Node.create_finalizer(@node))
        end

Go to Redland Home - Language Bindings Home - Ruby API Home

(C) Copyright 2004-2011 Dave Beckett, (C) Copyright 2004-2005 University of Bristol