Sha256: 3e54f16a732f383d04df8b91c90fbe16bf716fb0d84984eacbfab57d650ded09

Contents?: true

Size: 694 Bytes

Versions: 36

Compression:

Stored size: 694 Bytes

Contents

#! no set module

# Extracts all information needed to generate the link editor form
# from a link syntax string
class LinkParser
  attr_reader :name, :options, :field, :raw

  def self.new link_string
    return super if link_string.is_a? String

    OpenStruct.new(name: "", options: {}, raw: "[[ ]]")
  end

  def initialize link_string
    @raw = link_string
    link = Card::Content::Chunk::Link.new link_string, nil
    init_name link.name
    @options = link.options
  end

  def title
    @options && @options[:title]
  end

  def field?
    @field
  end

  private

  def init_name name
    @field = name.to_name.simple_relative?
    @name = @field ? name.to_s[1..-1] : name
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
card-mod-tinymce_editor-0.18.1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.18.0 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.17.0 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.16.0 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.6 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.5 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.4 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.3 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.2.pre1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.1.1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.15.0 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.14.2 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.14.1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.14.0 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.13.4 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.13.3 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.13.2 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.13.1 set/all/reference_editor/link_editor/link_parser.rb
card-mod-tinymce_editor-0.13.0 set/all/reference_editor/link_editor/link_parser.rb