Class: DataFoodConsortium::Connector::SKOSParserElement
- Inherits:
-
Object
- Object
- DataFoodConsortium::Connector::SKOSParserElement
- Defined in:
- lib/datafoodconsortium/connector/skos_parser_element.rb
Overview
MIT License
Copyright © 2023 Maxime Lecoq <maxime@lecoqlibre.fr>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Instance Attribute Summary collapse
-
#broader ⇒ Object
readonly
Returns the value of attribute broader.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #hasBroader ⇒ Object
-
#initialize(element) ⇒ SKOSParserElement
constructor
A new instance of SKOSParserElement.
- #isCollection? ⇒ Boolean
- #isConcept? ⇒ Boolean
Constructor Details
#initialize(element) ⇒ SKOSParserElement
Returns a new instance of SKOSParserElement.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 29 def initialize(element) @broader = [] if (element) @id = element["@id"] if (element["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]) @type = extractId(element["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]) elsif (element["@type"]) @type = extractId(element["@type"]) else @type = "undefined" end if (element["http://www.w3.org/2004/02/skos/core#broader"]) element["http://www.w3.org/2004/02/skos/core#broader"].each do |broader| @broader.push(broader["@id"]) end end else @id = "" @type = "" end end |
Instance Attribute Details
#broader ⇒ Object (readonly)
Returns the value of attribute broader.
27 28 29 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 27 def broader @broader end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
25 26 27 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 25 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
26 27 28 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 26 def type @type end |
Instance Method Details
#hasBroader ⇒ Object
54 55 56 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 54 def hasBroader() return @broader.count > 0 end |
#isCollection? ⇒ Boolean
62 63 64 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 62 def isCollection?() return @type == "http://www.w3.org/2004/02/skos/core#Collection" || @type == "skos:Collection" end |
#isConcept? ⇒ Boolean
58 59 60 |
# File 'lib/datafoodconsortium/connector/skos_parser_element.rb', line 58 def isConcept?() return @type == "http://www.w3.org/2004/02/skos/core#Concept" || @type == "skos:Concept" end |