Skip to content

Commit

Permalink
Integrate to 1 method
Browse files Browse the repository at this point in the history
  • Loading branch information
dtan4 committed May 1, 2014
1 parent 844a029 commit 0cd2f75
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions lib/md2pukiwiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ def self.convert(text)
text.lines.map do |line|
new_line = line.chomp

%w{decorated prefixed special}.each do |type|
new_line = self.send("convert_#{type}_text", new_line)
prefixed_type = %w{header list numbered_list}
decorated_type = %w{bold italic strikethrough}
special_type = %w{image link}

[prefixed_type, decorated_type, special_type].flatten.each do |type|
new_line = self.send("convert_#{type}", new_line)
end

new_line
Expand All @@ -15,36 +19,6 @@ def self.convert(text)

private

def self.convert_prefixed_text(line)
new_line = line.chomp

%w{header list numbered_list}.each do |method|
new_line = self.send("convert_#{method}", new_line)
end

new_line
end

def self.convert_decorated_text(line)
new_line = line.chomp

%w{bold italic strikethrough}.each do |method|
new_line = self.send("convert_#{method}", new_line)
end

new_line
end

def self.convert_special_text(line)
new_line = line.chomp

%w{image link}.each do |method|
new_line = self.send("convert_#{method}", new_line)
end

new_line
end

# "# header" => "*header"
def self.convert_header(line)
if /\A(?<sharps>#+) (?<header>.+)\z/ =~ line
Expand Down

0 comments on commit 0cd2f75

Please sign in to comment.