Class: MarkyMarkdown::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/marky_markdown.rb

Class Method Summary collapse

Class Method Details

.count_occurences_for(key, body) ⇒ Object



51
52
53
54
# File 'lib/marky_markdown.rb', line 51

def self.count_occurences_for(key, body)
  length = key.length
  body.count(key) / length
end

.shorten_str(str) ⇒ Object



37
38
39
40
41
42
# File 'lib/marky_markdown.rb', line 37

def self.shorten_str(str)
  str.slice(str.index('#') + 1..(str.index('$') - 1))
rescue StandardError => e
  puts e.message
  puts e.backtrace.inspect
end

.split_str_by_returns(str) ⇒ Object



44
45
46
47
48
49
# File 'lib/marky_markdown.rb', line 44

def self.split_str_by_returns(str)
  str.split("\r\n")
rescue StandardError => e
  puts e.message
  puts e.backtrace.inspect
end