Module: PubliSci::CustomPredicate
- Included in:
- Prov::Derivation, Prov::Element
- Defined in:
- lib/bio-publisci/mixins/custom_predicate.rb
Instance Method Summary collapse
Instance Method Details
#add_custom(str) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bio-publisci/mixins/custom_predicate.rb', line 19 def add_custom(str) if custom custom.map{|k,v| pk = k.respond_to?(:to_base) ? k.to_base : k v.map{|vv| if vv.is_a? Symbol deref = Prov.registry.values.map{|h| h[vv] if vv }.reject{|x| x==nil} raise "Unknown Element #{vv}" unless deref.size > 0 vv = RDF::Resource(deref.first) end str << "\t#{pk} #{vv.to_base} ;\n" } } end end |
#custom ⇒ Object
15 16 17 |
# File 'lib/bio-publisci/mixins/custom_predicate.rb', line 15 def custom @custom end |
#has(predicate, object) ⇒ Object Also known as: set
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/bio-publisci/mixins/custom_predicate.rb', line 3 def has(predicate, object) if object.is_a? Symbol obj = object else predicate = RDF::Resource(predicate) if RDF::Resource(predicate).valid? obj = RDF::Resource(object) obj = RDF::Literal(object) unless obj.valid? end ((@custom ||= {})[predicate] ||= []) << obj end |