Class: Meteor::ParserFactory
- Inherits:
-
Object
- Object
- Meteor::ParserFactory
- Defined in:
- lib/meteor.rb
Overview
パーサファクトリクラス
Constant Summary collapse
- ABST_EXT_NAME =
'.*'
- CURRENT_DIR =
'.'
- SLASH =
'/'
- ENC_UTF8 =
'UTF-8'
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
- String
-
基準ディレクトリ.
-
#base_encoding ⇒ Object
- String
-
デフォルトエンコーディング.
Instance Method Summary collapse
-
#[](key) ⇒ Meteor::Parser
パーサを取得する.
-
#[]=(key, ps) ⇒ Object
パーサをセットする.
-
#initialize(*args) ⇒ ParserFactory
constructor
イニシャライザ.
-
#initialize_2(bs_dir, bs_encoding) ⇒ Object
イニシャライザ.
- #parser(*args) ⇒ Object
-
#parser_str(type, relative_url, document) ⇒ Meteor::ParserFactory
パーサをセットする.
Constructor Details
#initialize ⇒ ParserFactory #initialize(bs_dir) ⇒ ParserFactory #initialize(bs_dir, bs_encoding) ⇒ ParserFactory
イニシャライザ
650 651 652 653 654 655 656 657 658 659 660 661 |
# File 'lib/meteor.rb', line 650 def initialize(*args) case args.length when 0 then initialize_0 when 1 then initialize_1(args[0]) when 2 then initialize_2(args[0],args[1]) else raise ArgumentError end end |
Instance Attribute Details
#base_dir ⇒ Object
- String
-
基準ディレクトリ
638 639 640 |
# File 'lib/meteor.rb', line 638 def base_dir @base_dir end |
#base_encoding ⇒ Object
- String
-
デフォルトエンコーディング
639 640 641 |
# File 'lib/meteor.rb', line 639 def base_encoding @base_encoding end |
Instance Method Details
#[](key) ⇒ Meteor::Parser
パーサを取得する
848 849 850 |
# File 'lib/meteor.rb', line 848 def [](key) self.parser(key) end |
#[]=(key, ps) ⇒ Object
パーサをセットする
839 840 841 |
# File 'lib/meteor.rb', line 839 def []=(key,ps) @cache[path] = ps end |
#initialize_2(bs_dir, bs_encoding) ⇒ Object
イニシャライザ
689 690 691 692 693 |
# File 'lib/meteor.rb', line 689 def initialize_2(bs_dir,bs_encoding) @cache = Hash.new @base_dir = bs_dir @base_encoding = bs_encoding end |
#parser(type, relative_path, encoding) ⇒ Meteor::Parser #parser(type, relative_path) ⇒ Meteor::Parser #parser(key) ⇒ Meteor::Parser
713 714 715 716 717 718 719 720 721 722 |
# File 'lib/meteor.rb', line 713 def parser(*args) case args.length when 1 then parser_1(args[0]) when 2 then parser_2(args[0],args[1]) when 3 then parser_3(args[0],args[1],args[2]) end end |
#parser_str(type, relative_url, document) ⇒ Meteor::ParserFactory
パーサをセットする
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
# File 'lib/meteor.rb', line 817 def parser_str(type,relative_url,document) case type when Parser::HTML then html = Meteor::Core::Html::ParserImpl.new() html.parse(document) @cache[relative_url] = html when Parser::XHTML then xhtml = Meteor::Core::Xhtml::ParserImpl.new() xhtml.parse(document) @cache[relative_url] = xhtml when Parser::XML then xml = Meteor::Core::Xml::ParserImpl.new() xml.parse(document) @cache[relative_url] = xml end end |