Sha256: 157fac4b4580832f0819220d1cf6faf520451cd5337b6159fa3ce9b548c3d67e
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
module Chronicle module Schema # Represents a property in the RDF graph class SchemaProperty attr_reader :id attr_accessor :domain, :range, :comment, :many, :required, :namespace, :range_types, # FIXME :see_also def initialize(id) @id = id @domain = [] @range = [] @many = false @required = false yield self if block_given? end def pretty_print(pp) pp.text("SchemaProperty: #{id}") pp.nest(2) do pp.breakable pp.text("Range: #{range}") pp.breakable pp.text("Domain: #{domain}") end end def to_h output = { id:, domain:, range:, many: @many, required: @required } output[:comment] = @comment if @comment output[:see_also] = @see_also if @see_also output end def ==(other) id == other.id end def required? @required end def many? @many end def identifier @id.split('/').last&.to_sym end # FIXME def id_snakecase @id.split('/').last.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym end # FIXME: refactor this and the next def range_identifiers range.map do |r| r.split('/').last&.to_sym end end def full_range_identifiers range_types.map(&:descendants).flatten.map { |x| x.id.split('/').last&.to_sym } + range_identifiers end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
chronicle-core-0.3.2 | lib/chronicle/schema/schema_property.rb |
chronicle-core-0.3.1 | lib/chronicle/schema/schema_property.rb |
chronicle-core-0.3.0 | lib/chronicle/schema/schema_property.rb |