Sha256: fae94fea3e27fa652752ca5236eaec321b83c1f6aceef19f54c95342086d26e2

Contents?: true

Size: 747 Bytes

Versions: 2

Compression:

Stored size: 747 Bytes

Contents

module RTM
  # Some helpers for locators which could ideally mixed into String and Locator.
  # Anyway, they are not here to not clutter up the namespace too much.
  module LocatorHelpers
    # removes "=" (and possible whitespace thereafter) from the beginning of a String or Locator if it is there
    def self.slo2iri(slo)
      slo = slo.to_s
      slo = slo[1..-1].lstrip if slo[0] == "="[0] # remove = if slo starts with it
      slo
    end

    # prepends "=" to a String or Locator if it is not already there.
    def self.iri2slo(iri)
      return "=#{iri}" if slo[0] == "="[0]
      iri
    end

    # returns true if the String or Locator given starts with "=" 
    def self.is_a_slo?(iri)
      iri.to_s[0] == "="[0]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rtm-0.1.1 lib/rtm/locator_helpers.rb
rtm-0.1.0 lib/rtm/locator_helpers.rb