Redland RDF Language Bindings - Ruby RDoc - Class: Redland::Literal

### Home Classes Methods

### In Files

- rdf/redland/node.rb

### Parent

Redland::Node

### Methods

- ::from_node
- ::from_xml
- ::new

### Included Modules

- Redland

### Files

- Makefile
- Makefile
- Makefile
- Makefile

### Class/Module Index

Quicksearch

- Redland
- Redland::BNode
- Redland::ContextParser
- Redland::FileStore
- Redland::HashOpen
- Redland::HashStore
- Redland::Literal
- Redland::MemoryStore
- Redland::MergedModel
- Redland::Model
- Redland::Namespace
- Redland::Node
- Redland::NodeIterator
- Redland::NodeTypeError
- Redland::OWL
- Redland::Parser
- Redland::Query
- Redland::QueryResults
- Redland::RDFS
- Redland::RedlandError
- Redland::Resource
- Redland::Serializer
- Redland::Statement
- Redland::Stream
- Redland::TripleStore
- Redland::Uri
- Redland::Util
- Redland::World
- DC
- FOAF

No matching classes.

# Redland::Literal

A literal node

### Attributes

language[R]

the language of the literal

value[R]

the string value of the literal

### Public Class Methods

from_node(node) click to toggle source

create a literal from another Node

    # 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) click to toggle source

create a literal from and xml string

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

    # 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) click to toggle source

create a new Literal node

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

    # 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-2013 Dave Beckett, (C) Copyright 2004-2005 University of Bristol