Sha256: ee9b2adc356bd2c94fa21e2620cbc44fcdbb0be241bba98020ee6388e55074d2
Contents?: true
Size: 734 Bytes
Versions: 44
Compression:
Stored size: 734 Bytes
Contents
# frozen_string_literal: true module SublimeTextKit module Snippets KEY_MAP = { "content" => :content, "tabTrigger" => :trigger, "description" => :description, "scope" => :scope }.freeze # Defines a snippet record. Model = Struct.new(*KEY_MAP.values, keyword_init: true) do def self.for document, key_map: KEY_MAP root = document.root return new unless root root.elements .reduce({}) { |attributes, element| attributes.merge element.name => element.text } .transform_keys(key_map) .then { |attributes| new(**attributes) } end def initialize *arguments super freeze end end end end
Version data entries
44 entries across 44 versions & 1 rubygems