Class: Middleman::Emojifire::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-emojifire/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Content

Returns a new instance of Content.



6
7
8
# File 'lib/middleman-emojifire/content.rb', line 6

def initialize(source)
  @source = source.to_s
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



4
5
6
# File 'lib/middleman-emojifire/content.rb', line 4

def source
  @source
end

Instance Method Details

#body_onlyObject



14
15
16
17
18
# File 'lib/middleman-emojifire/content.rb', line 14

def body_only
  source.gsub(%r{<body.*?>(.*?)</body>}m) do |match|
    yield match
  end
end

#include_body?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/middleman-emojifire/content.rb', line 10

def include_body?
  source =~ %r{<body.*?>.*?</body>}m ? true : false
end

#to_sObject



20
21
22
# File 'lib/middleman-emojifire/content.rb', line 20

def to_s
  source
end