This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_triangle(size) | |
print_top_row_of_triangle(size) | |
return if size <= 1 | |
print_middle_section_of_triangle(size) | |
print_bottom_of_triangle(size) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_triangle(size) | |
print_top_row_of_triangle(size) | |
return if size <= 1 | |
print_middle_section_of_triangle(size) | |
print_bottom_of_triangle(size) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
def self.parse_youtube_id(url) | |
#url = "http://www.youtube.com/watch?v=E4Fbk52Mk1w" | |
url =~ /[vV]=([^&]*)/ | |
id = $1 | |
if id.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
class TagInfo | |
def initialize(tag_info, tags) | |
@tag_data = find_tag_info(tag_info) | |
@tags = tags | |
@tag = @tags[@tag_data[:tag].to_sym] unless @tag_data[:tag].nil? | |
end | |
def [](key) | |
@tag_data[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
class TagInfo | |
def initialize(tag_info, tags) | |
@tag_data = find_tag_info(tag_info) | |
@tags = tags | |
@tag = @tags[@tag_data[:tag].to_sym] unless @tag_data[:tag].nil? | |
end | |
def [](key) | |
@tag_data[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
class TagInfo | |
def initialize(tag_info, tags) | |
@tag_data = find_tag_info(tag_info) | |
@tags = tags | |
@tag = @tags[@tag_data[:tag].to_sym] unless @tag_data[:tag].nil? | |
end | |
def [](key) | |
@tag_data[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
class TagInfo | |
def initialize(tag_info, tags) | |
@tag_data = find_tag_info(tag_info) | |
@tags = tags | |
@tag = @tags[@tag_data[:tag].to_sym] unless @tag_data[:tag].nil? | |
end | |
def [](key) | |
@tag_data[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyBBCode | |
class TagInfo | |
def initialize(tag_info, tags) | |
@tag_data = find_tag_info(tag_info) | |
@tags = tags | |
@tag = @tags[@tag_data[:tag].to_sym] unless @tag_data[:tag].nil? | |
end | |
def [](key) | |
@tag_data[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.parse(text, tags = {}) | |
tags = @@tags if tags == {} | |
@tag_collection = TagCollection.new(text, tags) | |
@tag_collection.process_text | |
if @tag_collection.invalid? | |
@tag_collection.errors | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_text | |
@text.scan(/((\[ (\/)? (\w+) ((=[^\[\]]+) | (\s\w+=\w+)* | ([^\]]*))? \]) | ([^\[]+))/ix) do |tag_info| | |
@ti = TagInfo.new(tag_info, @defined_tags) | |
@ti.handle_unregistered_tags_as_text # if the tag isn't in the @defined_tags list, then treat it as text | |
return if !valid_element? | |
# Validation of tag succeeded, add to @tags_list and/or bbtree | |
if @ti.element_is_opening_tag? | |
element = {:is_tag => true, :tag => @ti[:tag].to_sym, :nodes => [] } |
OlderNewer