Class: RoadForest::MediaType::Handlers::RDFPost::Reader::St::State

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/content-handling/type-handlers/rdfpost.rb

Instance Method Summary collapse

Constructor Details

#initialize(reader) ⇒ State

Returns a new instance of State.



13
14
15
16
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 13

def initialize(reader)
  @reader = reader
  @accept_hash = cleanup(accept_list)
end

Instance Method Details

#accept(key, value) ⇒ Object



75
76
77
78
79
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 75

def accept(key, value)
  #puts "#{[self.class.to_s.sub(/.*:/,''), key,
  #value.sub(/\s*\Z/,'')].inspect}"
  @accept_hash[key][value.sub(/\s*\Z/,'')]
end

#base_uriObject



31
32
33
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 31

def base_uri
  ::RDF::URI.intern(@reader.options[:base_uri])
end

#blank_node(name) ⇒ Object



27
28
29
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 27

def blank_node(name)
  ::RDF::Node.new(name)
end

#cleanup(accept_list) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 18

def cleanup(accept_list)
  hash = Hash.new{ accept_list[nil] }
  accept_list.each_key do |key|
    next if key.nil?
    hash[key.to_s] = accept_list[key]
  end
  hash
end

#clear_objectObject



53
54
55
56
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 53

def clear_object
  @reader.object = nil
  @reader.object_prefix = nil
end

#clear_predicateObject



48
49
50
51
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 48

def clear_predicate
  @reader.predicate = nil
  @reader.predicate_prefix = nil
end

#clear_subjectObject



43
44
45
46
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 43

def clear_subject
  @reader.subject = nil
  @reader.subject_prefix = nil
end

#consumeObject



63
64
65
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 63

def consume
  @reader.consume_pair
end

#consume_next(name) ⇒ Object



58
59
60
61
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 58

def consume_next(name)
  consume
  next_state(name)
end

#next_state(name) ⇒ Object



71
72
73
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 71

def next_state(name)
  @reader.current_state = @reader.states.fetch(name)
end

#prefix_uri(name) ⇒ Object



39
40
41
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 39

def prefix_uri(name)
  ::RDF::URI.intern(@reader.options[:prefixes][name])
end

#triple_completeObject



67
68
69
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 67

def triple_complete
  @reader.new_triple = true
end

#uri(string) ⇒ Object



35
36
37
# File 'lib/roadforest/content-handling/type-handlers/rdfpost.rb', line 35

def uri(string)
  base_uri.join(string)
end