This file contains hidden or 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
| formatter = HtmlFormatter.new | |
| g = Generator.new(formatter, 'title', 'my long and interesting text') | |
| g.make_report |
This file contains hidden or 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
| class Generator | |
| def initialize(reporter, title, text) | |
| @reporter = reporter | |
| @title = title | |
| @text = text | |
| end | |
| def make_report | |
| @reporter.output_report(title, text) | |
| end |
This file contains hidden or 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
| class Formatter | |
| def output_report(title, text) | |
| raise 'Abstract method called' | |
| end | |
| end | |
| class HtmlFormatter < Formatter | |
| def output_report(title, text) | |
| <<-EOF | |
| <html> |
This file contains hidden or 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
| class MyClass | |
| def do_somth_with_class(class) | |
| class.send(method.to_sym) | |
| other_stuff | |
| end | |
| end |
This file contains hidden or 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
| class MyClass | |
| def do_somth_with_class | |
| OtherClass.method | |
| other_stuff | |
| end | |
| end |
This file contains hidden or 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
| class HtmlReporter < SomthingElse | |
| include Reporter | |
| protected | |
| # реализация методов для html-версии | |
| def make_header | |
| end | |
| def make_body |
This file contains hidden or 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
| class Report | |
| def make_report(data) | |
| make_header | |
| make_body | |
| make_footer | |
| end | |
| protected | |
| # методы ничего не реализуют |
This file contains hidden or 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
| class HtmlReporter | |
| def make_report(data) | |
| make_html_header | |
| make_html_body | |
| make_html_footer | |
| end | |
| end | |
| class PdfReporter | |
| def make_report(data) |
This file contains hidden or 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
| class HtmlReporter | |
| def make_report(data) | |
| make_html_header | |
| make_html_body | |
| make_html_footer | |
| end | |
| end |
This file contains hidden or 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
| it "should get followers count" do | |
| VCR.use_cassette('twi_followers_count') do | |
| MyModel.followers_count(@user).should == 3 | |
| end | |
| end |