Class: SocialSnippet::Resolvers::InsertResolver

Inherits:
BaseResolver
  • Object
show all
Defined in:
lib/social_snippet/resolvers/insert_resolver.rb

Instance Attribute Summary collapse

Attributes inherited from BaseResolver

#social_snippet, #visited

Instance Method Summary collapse

Methods inherited from BaseResolver

#each_snip_tags

Constructor Details

#initialize(social_snippet) ⇒ InsertResolver

Constructor


10
11
12
13
# File 'lib/social_snippet/resolvers/insert_resolver.rb', line 10

def initialize(social_snippet)
  @deps_resolver = Resolvers::DepResolver.new(social_snippet)
  super(social_snippet)
end

Instance Attribute Details

#deps_resolverObject (readonly)

Returns the value of attribute deps_resolver


5
6
7
# File 'lib/social_snippet/resolvers/insert_resolver.rb', line 5

def deps_resolver
  @deps_resolver
end

Instance Method Details

#insert(src) ⇒ Object

Insert snippets to given text


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/social_snippet/resolvers/insert_resolver.rb', line 18

def insert(src)
  context = Context.new("")
  lines = src.split("\n")

  TagParser.find_snippet_tags(lines).each do |tag_info|
    visit tag_info[:tag]
  end

  dest = insert_func(lines, context)
  return dest.join("\n")
end