Class: Meteor::Core::Kernel
- Inherits:
-
Parser
- Object
- Parser
- Meteor::Core::Kernel
- Defined in:
- lib/meteor.rb,
lib/meteor.rb
Overview
Parser Core Class (パーサコアクラス)
Direct Known Subclasses
Ml::Html::ParserImpl, Ml::Xhtml::ParserImpl, Ml::Xml::ParserImpl
Constant Summary
- EMPTY =
''- SPACE =
' '- DOUBLE_QUATATION =
'"'- TAG_OPEN =
'<'- TAG_OPEN3 =
'</'- TAG_CLOSE =
TAG_OPEN4 = '<\\/'
'>'- TAG_CLOSE3 =
TAG_CLOSE2 = '\/>'
'/>'- ATTR_EQ =
'="'- TAG_SEARCH_1_1 =
element
'(|\\s[^<>]*)>(((?!('- TAG_SEARCH_1_2 =
'[^<>]*>)).)*)<\\/'- TAG_SEARCH_1_3 =
'(|\\s[^<>]*)\\/>'- TAG_SEARCH_1_4 =
'(\\s[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_1_4_2 =
'(|\\s[^<>]*)>'- TAG_SEARCH_NC_1_1 =
'(?:|\\s[^<>]*)>((?!('- TAG_SEARCH_NC_1_2 =
'[^<>]*>)).)*<\\/'- TAG_SEARCH_NC_1_3 =
'(?:|\\s[^<>]*)\\/>'- TAG_SEARCH_NC_1_4 =
'(?:\\s[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_NC_1_4_2 =
'(?:|\\s[^<>]*)>'- TAG_SEARCH_2_1 =
'(\\s[^<>]*'- TAG_SEARCH_2_1_2 =
'(\\s[^<>]*(?:'- TAG_SEARCH_2_2 =
'"[^<>]*)>(((?!('- TAG_SEARCH_2_2_2 =
'")[^<>]*)>(((?!('- TAG_SEARCH_2_3 =
'"[^<>]*)'- TAG_SEARCH_2_3_2 =
'"[^<>]*)\\/>'- TAG_SEARCH_2_3_2_2 =
'")[^<>]*)\\/>'- TAG_SEARCH_2_4 =
'(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_2_4_2 =
'(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))'- TAG_SEARCH_2_4_2_2 =
'")([^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>)))'- TAG_SEARCH_2_4_2_3 =
'"'- TAG_SEARCH_2_4_3 =
'"[^<>]*)>'- TAG_SEARCH_2_4_3_2 =
'")[^<>]*)>'- TAG_SEARCH_2_4_4 =
'"[^<>]*>'- TAG_SEARCH_2_6 =
'"[^<>]*'- TAG_SEARCH_2_7 =
'"|'- TAG_SEARCH_NC_2_1 =
'\\s[^<>]*'- TAG_SEARCH_NC_2_1_2 =
'\\s[^<>]*(?:'- TAG_SEARCH_NC_2_2 =
'"[^<>]*>((?!('- TAG_SEARCH_NC_2_2_2 =
'")[^<>]*>((?!('- TAG_SEARCH_NC_2_3 =
'"[^<>]*)'- TAG_SEARCH_NC_2_3_2 =
'"[^<>]*\\/>'- TAG_SEARCH_NC_2_3_2_2 =
'")[^<>]*\\/>'- TAG_SEARCH_NC_2_4 =
'(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_NC_2_4_2 =
'(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_NC_2_4_2_2 =
'")(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_NC_2_4_2_3 =
'"'- TAG_SEARCH_NC_2_4_3 =
'"[^<>]*>'- TAG_SEARCH_NC_2_4_3_2 =
'")[^<>]*>'- TAG_SEARCH_NC_2_4_4 =
'"[^<>]*>'- TAG_SEARCH_NC_2_6 =
'"[^<>]*'- TAG_SEARCH_NC_2_7 =
'"|'- TAG_SEARCH_3_1 =
'<([^<>"]*)\\s[^<>]*'- TAG_SEARCH_3_1_2 =
'<([^<>"]*)\\s([^<>]*'- TAG_SEARCH_3_1_2_2 =
'<([^<>"]*)\\s([^<>]*('- TAG_SEARCH_3_2 =
'"[^<>]*\\/>'- TAG_SEARCH_3_2_2 =
'"[^<>]*)\\/>'- TAG_SEARCH_3_2_2_2 =
'")[^<>]*)\\/>'- TAG_SEARCH_4_1 =
'(\\s[^<>\\/]*)>('- TAG_SEARCH_4_2 =
'.*?<'- TAG_SEARCH_4_3 =
'(\\s[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'- TAG_SEARCH_4_4 =
'<\\/'- TAG_SEARCH_4_5 =
'.*?<\/'- TAG_SEARCH_4_6 =
'.*?)<\/'- TAG_SEARCH_4_7 =
'"(?:[^<>\\/]*>|(?!([^<>]*\\/>))[^<>]*>))('- TAG_SEARCH_4_7_2 =
'")(?:[^<>\\/]*>|(?!([^<>]*\\/>))[^<>]*>))('- TAG_SEARCH_NC_3_1 =
'<[^<>"]*\\s[^<>]*'- TAG_SEARCH_NC_3_1_2 =
'<([^<>"]*)\\s(?:[^<>]*'- TAG_SEARCH_NC_3_1_2_2 =
'<([^<>"]*)\\s(?:[^<>]*('- TAG_SEARCH_NC_3_2 =
'"[^<>]*\\/>'- TAG_SEARCH_NC_3_2_2 =
'"[^<>]*)\\/>'- TAG_SEARCH_NC_3_2_2_2 =
'")[^<>]*)\\/>'- PATTERN_FIND_1 =
find
'^([^,\\[\\]#\\.]+)$'- PATTERN_FIND_2_1 =
'^#([^\\.,\\[\\]#][^,\\[\\]#]*)$'- PATTERN_FIND_2_2 =
'^\\.([^\\.,\\[\\]#][^,\\[\\]#]*)$'- PATTERN_FIND_2_3 =
'^\\[([^\\[\\],]+)=([^\\[\\],]+)\\]$'- PATTERN_FIND_3 =
'^([^\\.,\\[\\]#][^,\\[\\]#]*)\\[([^,\\[\\]]+)=([^,\\[\\]]+)\\]$'- PATTERN_FIND_4 =
'^\\[([^,]+)=([^,]+)\\]\\[([^,]+)=([^,]+)\\]$'- PATTERN_FIND_5 =
'^([^\\.,\\[\\]#][^,\\[\\]#]*)\\[([^,]+)=([^,]+)\\]\\[([^,]+)=([^,]+)\\]$'- SET_ATTR_1 =
setAttribute
'="[^"]*"'- GET_ATTR_1 =
getAttributeValue
'="([^"]*)"'- GET_ATTRS_MAP =
attributeMap
'([^\\s]*)="([^\"]*)"'- ERASE_ATTR_1 =
removeAttribute
'="[^"]*"\\s?'- SEARCH_CX_1 =
'<!--\\s@'- SEARCH_CX_2 =
SEARCH_CX_1 = "<!--\s@"
'\\s([^<>]*id="'- SEARCH_CX_3 =
SEARCH_CX_2 = "\s(*id=""
'"[^<>]*)-->(((?!(<!--\\s/@'- SEARCH_CX_4 =
SEARCH_CX_3 = ""[^<>]*)-->(((?!(<!--\s/@"
')).)*)<!--\\s/@'- SEARCH_CX_5 =
SEARCH_CX_4 = ")).)*)<!--\s/@"
'\\s-->'- SEARCH_CX_6 =
SEARCH_CX_5 = "\s-->"
'<!--\\s@([^<>]*)\\s[^<>]*id="'- SET_CX_1 =
setElementToCXTag
'<!-- @'- SET_CX_2 =
'-->'- SET_CX_3 =
'<!-- /@'- SET_CX_4 =
' -->'- SET_MONO_1 =
setMonoInfo
'\\A[^<>]*\\Z'- CLEAN_1 =
clean
'<!--\\s@[^<>]*\\s[^<>]*(\\s)*-->'- CLEAN_2 =
'<!--\\s\\/@[^<>]*(\\s)*-->'- AND_1 =
escape
'&'- AND_2 =
'&'- AND_3 =
'amp'- LT_1 =
'<'- LT_2 =
'<'- LT_3 =
'lt'- GT_1 =
'>'- GT_2 =
'>'- GT_3 =
'gt'- QO_2 =
'"'- QO_3 =
'quot'- AP_1 =
'\''- AP_2 =
'''- AP_3 =
'apos'- EN_1 =
EN_1 = "\\"
"\\"- ESCAPE_ENTITY_REF =
EN_2 = "\\\\" DOL_1 = "\$" DOL_2 = "\\\$" PLUS_1 = "\+" PLUS_2 = "\\+"
''- MODE_UTF8 =
'r:UTF-8'- MODE_BF =
'r:'- MODE_AF =
':utf-8'- MODE =
'r'- @@pattern_find_1 =
Regexp.new(PATTERN_FIND_1)
- @@pattern_find_2_1 =
Regexp.new(PATTERN_FIND_2_1)
- @@pattern_find_2_2 =
Regexp.new(PATTERN_FIND_2_2)
- @@pattern_find_2_3 =
Regexp.new(PATTERN_FIND_2_3)
- @@pattern_find_3 =
Regexp.new(PATTERN_FIND_3)
- @@pattern_find_4 =
Regexp.new(PATTERN_FIND_4)
- @@pattern_find_5 =
Regexp.new(PATTERN_FIND_5)
- @@pattern_set_mono1 =
Regexp.new(SET_MONO_1)
- @@pattern_get_attrs_map =
@@pattern_sub_regex1 = Regexp.new(SUB_REGEX1)
Regexp.new(GET_ATTRS_MAP)
- @@pattern_clean1 =
Regexp.new(CLEAN_1)
- @@pattern_clean2 =
Regexp.new(CLEAN_2)
Constants inherited from Parser
HTML, HTML5, XHTML, XHTML5, XML
Instance Attribute Summary (collapse)
-
- (Object) doc_type
- Fixnum
-
document type (ドキュメントタイプ).
-
- (Object) document_hook
- String
-
hook document (フック・ドキュメント).
-
- (Object) element_cache
- Hash
-
element cache (要素キャッシュ).
-
- (Object) element_hook
- Meteor::Element
-
element (要素).
Instance Method Summary (collapse)
- - (Object) attr(elm, attrs, *args)
- - (Object) attr_map(*args)
-
- (String) character_encoding
get character encoding (文字エンコーディングを取得する).
-
- (Object) character_encoding=(enc)
set character encoding (文字エンコーディングをセットする).
- - (Object) content(*args)
- - (Object) create_element_pattern
-
- (Object) cxtag(*args)
get cx(comment extension) tag (CX(コメント拡張)タグを取得する).
-
- (String) document
get document (ドキュメントを取得する).
-
- (Object) document=(doc)
set document (ドキュメントをセットする).
-
- (Object) element(elm, attrs = nil, *args)
get element (要素を取得する).
- - (Object) execute(*args)
-
- (Meteor::Element) find(selector)
get element using selector (要素を取得する).
-
- (Object) flush
reflect (反映する).
-
- (Kernel) initialize
constructor
initializer (イニシャライザ).
-
- (Object) read(file_path, encoding)
read file , set in parser (ファイルを読み込み、パーサにセットする).
-
- (Object) remove_element(elm)
remove element (要素を消す).
-
- (Meteor::RootElement) root_element
get root element (ルート要素を取得する).
-
- (Meteor::Element) shadow(elm)
mirror element 要素を射影する.
Constructor Details
- (Kernel) initialize
initializer (イニシャライザ)
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 |
# File 'lib/meteor.rb', line 1364 def initialize #親要素 #@parent = nil #正規表現パターン #@pattern = nil #ルート要素 @root = RootElement.new @root.parser = self #要素キャッシュ @element_cache = Hash.new() #フックドキュメント @document_hook = '' end |
Instance Attribute Details
- (Object) doc_type
- Fixnum
-
document type (ドキュメントタイプ)
1397 1398 1399 |
# File 'lib/meteor.rb', line 1397 def doc_type @doc_type end |
- (Object) document_hook
- String
-
hook document (フック・ドキュメント)
1398 1399 1400 |
# File 'lib/meteor.rb', line 1398 def document_hook @document_hook end |
- (Object) element_cache
- Hash
-
element cache (要素キャッシュ)
1396 1397 1398 |
# File 'lib/meteor.rb', line 1396 def element_cache @element_cache end |
- (Object) element_hook
- Meteor::Element
-
element (要素)
1399 1400 1401 |
# File 'lib/meteor.rb', line 1399 def element_hook @element_hook end |
Instance Method Details
- (Meteor::Element) attr(elm, attr) - (Meteor::Element) attr(elm, attr_name, attr_value) - (String) attr(elm, attr_name)
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 |
# File 'lib/meteor.rb', line 2279 def attr(elm, attrs,*args) if attrs.kind_of?(String) case args.length when ZERO get_attr_value(elm, attrs) when ONE elm.document_sync = true set_attribute_3(elm, attrs,args[0]) end elsif attrs.kind_of?(Hash) && attrs.size == 1 elm.document_sync = true set_attribute_3(elm, attrs.keys[0], attrs.values[0]) else raise ArgumentError end end |
- (Meteor::Element) attr_map(elm, attr_map) - (Meteor::AttributeMap) attr_map(elm)
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 |
# File 'lib/meteor.rb', line 2387 def attr_map(*args) case args.length when ONE get_attr_map(args[0]) when TWO #if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(Meteor::AttributeMap) then args[0].document_sync = true set_attr_map(args[0], args[1]) #end else raise ArgumentError end end |
- (String) character_encoding
get character encoding (文字エンコーディングを取得する)
1413 1414 1415 |
# File 'lib/meteor.rb', line 1413 def character_encoding @root.character_encoding end |
- (Object) character_encoding=(enc)
set character encoding (文字エンコーディングをセットする)
1405 1406 1407 |
# File 'lib/meteor.rb', line 1405 def character_encoding=(enc) @root.character_encoding = enc end |
- (Meteor::Element) content(elm, content, entity_ref = true) - (Meteor::Element) content(elm, content) - (String) content(elm)
2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 |
# File 'lib/meteor.rb', line 2457 def content(*args) case args.length when ONE #if args[0].kind_of?(Meteor::Element) then get_content_1(args[0]) #else # raise ArgumentError #end when TWO #if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then args[0].document_sync = true set_content_2(args[0], args[1]) #else # raise ArgumentError #end when THREE args[0].document_sync = true set_content_3(args[0], args[1], args[2]) else raise ArgumentError end end |
- (Object) create_element_pattern
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 |
# File 'lib/meteor.rb', line 2178 def create_element_pattern @rx_document = @root.document while (@res = @pattern.match(@rx_document)) || @cnt > ZERO if @res then if @cnt > ZERO then @rx_document2 = @res.post_match @res = @pattern_2.match(@rx_document) if @res then @rx_document = @res.post_match if @rx_document2.length > @rx_document.length then @sbuf << @pattern_cc_1_2 @cnt += ONE @rx_document = @rx_document2 else @cnt -= ONE if @cnt != ZERO then @sbuf << @pattern_cc_2_1 else @sbuf << @pattern_cc_2_2 break end end else @sbuf << @pattern_cc_1_2 @cnt += ONE @rx_document = @rx_document2 end else @rx_document = @res.post_match @sbuf << @pattern_cc_1_1 @cnt += ONE end else if @cnt == ZERO then break end @res = @pattern_2.match(@rx_document) if @res then @cnt -= ONE if @cnt != ZERO then @sbuf << @pattern_cc_2_1 else @sbuf << @pattern_cc_2_2 break end @rx_document = @res.post_match else break end end @pattern = @pattern_1b end end |
- (Meteor::Element) cxtag(elm_name, id) - (Meteor::Element) cxtag(id)
get cx(comment extension) tag (CX(コメント拡張)タグを取得する)
2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 |
# File 'lib/meteor.rb', line 2578 def cxtag(*args) case args.length when ONE cxtag_1(args[0]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end when TWO cxtag_2(args[0], args[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end else raise ArgumentError end end |
- (String) document
get document (ドキュメントを取得する)
1392 1393 1394 |
# File 'lib/meteor.rb', line 1392 def document @root.document end |
- (Object) document=(doc)
set document (ドキュメントをセットする)
1384 1385 1386 |
# File 'lib/meteor.rb', line 1384 def document=(doc) @root.document = doc end |
- (Meteor::Element) element(elm_name) - (Meteor::Element) element(elm_name, attrs) - (Meteor::Element) element(attrs) - (Meteor::Element) element(elm_name, attr_name, attr_value) - (Meteor::Element) element(attr_name, attr_value) - (Meteor::Element) element(elm_name, attr_name1, attr_value1, attr_name2, attr_value2) - (Meteor::Element) element(attr_name1, attr_value1, attr_name2, attr_value2) - (Meteor::Element) element(elm)
get element (要素を取得する)
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 |
# File 'lib/meteor.rb', line 1495 def element(elm, attrs = nil,*args) if !attrs if elm.kind_of?(String) element_1(elm) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif elm.kind_of?(Meteor::Element) shadow(elm) elsif elm.kind_of?(Hash) if elm.size == ONE element_2(elm.keys[0], elm.values[0]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif elm.size == TWO element_4(elm.keys[0], elm.values[0], elm.keys[1], elm.values[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end else raise ArgumentError end else raise ArgumentError end elsif attrs.kind_of?(Hash) if attrs.size == ONE element_3(elm, attrs.keys[0], attrs.values[0]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif attrs.size == TWO element_5(elm, attrs.keys[0], attrs.values[0], attrs.keys[1], attrs.values[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end else @elm_ = nil raise ArgumentError end elsif attrs.kind_of?(String) case args.length when ZERO element_2(elm,attrs) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end when ONE element_3(elm, attrs, args[0]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end when TWO element_4(elm, attrs, args[0],args[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end when THREE element_5(elm, attrs, args[0],args[1],args[2]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end else @elm_ = nil raise ArgumentError end else @elm_ = nil raise ArgumentError end end |
- (Object) execute(elm, hook) - (Object) execute(elm, loop, list)
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 |
# File 'lib/meteor.rb', line 2850 def execute(*args) case args.length when TWO execute_2(args[0], args[1]) when THREE execute_3(args[0], args[1], args[2]) else raise ArgumentError end end |
- (Meteor::Element) find(selector)
get element using selector (要素を取得する)
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 |
# File 'lib/meteor.rb', line 1573 def find(selector) #puts selector if @res = @@pattern_find_1.match(selector) then element_1(@res[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_2_1.match(selector) then element_2('id', @res[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_3.match(selector) then element_3(@res[1], @res[2], @res[3]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_5.match(selector) then element_5(@res[1], @res[2], @res[3], @res[4], @res[5]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_2_3.match(selector) then element_2(@res[1], @res[2]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_4.match(selector) then element_4(@res[1], @res[2], @res[3], @res[4]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end elsif @res = @@pattern_find_2_2.match(selector) then element_2('class', @res[1]) if @elm_ then @element_cache.store(@elm_.object_id, @elm_) end else nil end end |
- (Object) flush
reflect (反映する)
2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 |
# File 'lib/meteor.rb', line 2746 def flush if self.element_hook then if self.element_hook.origin.mono then if self.element_hook.origin.cx then #@root.hookDocument << SET_CX_1 << @root.element.name << SPACE #@root.hookDocument << @root.element.attributes << SET_CX_2 #@root.hookDocument << @root.element.mixed_content << SET_CX_3 #@root.hookDocument << @root.element.name << SET_CX_4 self.document_hook << "<!-- @#{self.element_hook.name} #{self.element_hook.attributes}-->#{self.element_hook.mixed_content}<!-- /@#{self.element_hook.name} -->" else #@root.hookDocument << TAG_OPEN << @root.element.name #@root.hookDocument << @root.element.attributes << TAG_CLOSE << @root.element.mixed_content #@root.hookDocument << TAG_OPEN3 << @root.element.name << TAG_CLOSE self.document_hook << "<#{self.element_hook.name}#{self.element_hook.attributes}>#{self.element_hook.mixed_content}</#{self.element_hook.name}>" end self.element_hook = Element.new!(self.element_hook.origin, self) else reflect @_attributes = self.element_hook.attributes if self.element_hook.origin.cx then #@root.hookDocument << SET_CX_1 << @root.element.name << SPACE #@root.hookDocument << @_attributes << SET_CX_2 #@root.hookDocument << @root.document << SET_CX_3 #@root.hookDocument << @root.element.name << SET_CX_4 self.document_hook << "<!-- @#{self.element_hook.name} #{@_attributes}-->#{@root.document}<!-- /@#{self.element_hook.name} -->" else #@root.hookDocument << TAG_OPEN << @root.element.name #@root.hookDocument << @_attributes << TAG_CLOSE << @root.document #@root.hookDocument << TAG_OPEN3 << @root.element.name << TAG_CLOSE self.document_hook << "<#{self.element_hook.name}#{@_attributes}>#{@root.document}</#{self.element_hook.name}>" end self.element_hook = Element.new!(self.element_hook.origin, self) end else reflect @element_cache.clear #フック判定がFALSEの場合 clean end end |
- (Object) read(file_path, encoding)
read file , set in parser (ファイルを読み込み、パーサにセットする)
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 |
# File 'lib/meteor.rb', line 1430 def read(file_path, encoding) #try { @character_encoding = encoding #ファイルのオープン #読込及び格納 io = open(file_path, MODE) @root.document = io.read #@root.document = @root.document.kconv(get_encoding(), Kconv.guess(@root.document)) enc = Kconv.guess(@root.document) #enc = get_encoding if !Kconv::UTF8.equal?(enc) then @root.document = @root.document.kconv(Kconv::UTF8, enc) end #ファイルのクローズ io.close end |
- (Object) remove_element(elm)
remove element (要素を消す)
2561 2562 2563 2564 |
# File 'lib/meteor.rb', line 2561 def remove_element(elm) elm.removed = true nil end |
- (Meteor::RootElement) root_element
get root element (ルート要素を取得する)
1421 1422 1423 |
# File 'lib/meteor.rb', line 1421 def root_element @root end |
- (Meteor::Element) shadow(elm)
mirror element 要素を射影する
2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 |
# File 'lib/meteor.rb', line 2807 def shadow(elm) if elm.empty then #内容あり要素の場合 set_mono_info(elm) pif2 = create(self) @elm_ = Element.new!(elm, pif2) if !elm.mono then pif2.root_element.document = String.new(elm.mixed_content) else pif2.root_element.document = String.new(elm.document) end @elm_ end end |