Module: TextUtils::TagHelper

Defined in:
lib/textutils/helper/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#find_tags(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/textutils/helper/tag_helper.rb', line 13

def find_tags( value )
  # logger.debug "   found tags: >>#{value}<<"

  tag_keys = value.split('|')

  ## unify; replace _w/ space; remove leading n trailing whitespace
  tag_keys = tag_keys.map do |key|
    key = key.gsub( '_', ' ' )
    key = key.strip
    key
  end

  tag_keys # return tag keys as ary
end

#find_tags_in_attribs!(attribs) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/textutils/helper/tag_helper.rb', line 28

def find_tags_in_attribs!( attribs )
  # NB: will remove :tags from attribs hash

  if attribs[:tags].present?
    tag_keys = find_tags( attribs[:tags] )
    attribs.delete(:tags)
    tag_keys   # return tag keys as ary of strings
  else
    []  # nothing found; return empty ary
  end
end