Class: Tattoo::Ink
- Inherits:
-
Object
- Object
- Tattoo::Ink
- Defined in:
- lib/tattoo/ink.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #find_markings(text) ⇒ Object
-
#initialize(name, regexp, opts = {}) ⇒ Ink
constructor
A new instance of Ink.
- #mark(marking, text) ⇒ Object
Constructor Details
#initialize(name, regexp, opts = {}) ⇒ Ink
Returns a new instance of Ink.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tattoo/ink.rb', line 9 def initialize(name, regexp, opts={}) @name = name.to_sym @regexp = regexp = opts.dup @prefix = .delete(:prefix) || DEFAULT_MARK_IDENTIFIER @token = .delete(:token) || DEFAULT_TOKEN @host = .delete(:host) || DEFAULT_HOST @url = .delete(:url).to_s @attributes = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/tattoo/ink.rb', line 7 def name @name end |
Instance Method Details
#find_markings(text) ⇒ Object
25 26 27 |
# File 'lib/tattoo/ink.rb', line 25 def find_markings(text) text.scan(/#{prefix_regexp}#{@regexp}/).flatten end |
#mark(marking, text) ⇒ Object
21 22 23 |
# File 'lib/tattoo/ink.rb', line 21 def mark(marking, text) text.gsub(/#{@prefix}#{marking}/, link_tag_for(marking)) end |