when_exe 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +333 -212
 - data/bin/make_ttl.rb +37 -0
 - data/bin/make_ttl.rb.config +9 -0
 - data/lib/when_exe.rb +923 -925
 - data/lib/when_exe/calendarnote.rb +9 -5
 - data/lib/when_exe/coordinates.rb +2437 -2446
 - data/lib/when_exe/inspect.rb +1480 -1408
 - data/lib/when_exe/linkeddata.rb +574 -0
 - data/lib/when_exe/locales/akt.rb +177 -176
 - data/lib/when_exe/locales/locale.rb +751 -751
 - data/lib/when_exe/mini_application.rb +307 -307
 - data/lib/when_exe/parts/resource.rb +1115 -1103
 - data/lib/when_exe/region/chinese/epochs.rb +6 -5
 - data/lib/when_exe/region/christian.rb +831 -829
 - data/lib/when_exe/region/japanese.rb +93 -93
 - data/lib/when_exe/region/japanese/notes.rb +1510 -1495
 - data/lib/when_exe/region/japanese/residues.rb +13 -13
 - data/lib/when_exe/tmposition.rb +2307 -2273
 - data/lib/when_exe/tmreference.rb +1744 -1734
 - data/lib/when_exe/version.rb +2 -2
 - data/link_to_online_documents +1 -1
 - data/test/scripts/3.ext.rb +6 -6
 - data/test/scripts/3.rb +6 -6
 - data/test/test.rb +76 -75
 - data/test/test/icalendar.rb +883 -879
 - data/test/test/linkeddata.rb +224 -0
 - data/test/test/region/m17n.rb +193 -193
 - data/when_exe.gemspec +3 -2
 - metadata +13 -6
 
| 
         @@ -1,1103 +1,1115 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- coding: utf-8 -*-
         
     | 
| 
       2 
     | 
    
         
            -
            =begin
         
     | 
| 
       3 
     | 
    
         
            -
              Copyright (C) 2011- 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
         
     | 
| 
       6 
     | 
    
         
            -
            =end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            # 本ライブラリのための諸々の部品
         
     | 
| 
       10 
     | 
    
         
            -
            #
         
     | 
| 
       11 
     | 
    
         
            -
            module When::Parts
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              #
         
     | 
| 
       14 
     | 
    
         
            -
              # Resource which has 'International Resource Identifier'
         
     | 
| 
       15 
     | 
    
         
            -
              #
         
     | 
| 
       16 
     | 
    
         
            -
              module Resource
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                # @private
         
     | 
| 
       19 
     | 
    
         
            -
                LabelProperty = nil
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                # @private
         
     | 
| 
       22 
     | 
    
         
            -
                ConstTypes = {
         
     | 
| 
       23 
     | 
    
         
            -
                  'SolarTerms'  => ['CalendarNote',     '%sSolarTerms',  '_n:%sSolarTerms%s' ],
         
     | 
| 
       24 
     | 
    
         
            -
                  'LunarPhases' => ['LunarPhases',      '%sLunarPhases', '_n:%sLunarPhases%s'],
         
     | 
| 
       25 
     | 
    
         
            -
                  'Terms'       => ['BasicTypes::M17n', '%s',            '_m:%s%s'           ],
         
     | 
| 
       26 
     | 
    
         
            -
                  'Era'         => ['TM::CalendarEra',  '%s',            '_e:%s%s'           ],
         
     | 
| 
       27 
     | 
    
         
            -
                  'Residue'     => ['Coordinates',      '%s',            '_co:%s%s'          ],
         
     | 
| 
       28 
     | 
    
         
            -
                  'Week'        => ['CalendarNote',     '%sWeek',        '_n:%sWeek%s'       ],
         
     | 
| 
       29 
     | 
    
         
            -
                  'Note'        => ['CalendarNote',     '%s',            '_n:%s%s'           ],
         
     | 
| 
       30 
     | 
    
         
            -
                  'Notes'       => ['CalendarNote',     '%s',            '_n:%s/Notes%s'     ],
         
     | 
| 
       31 
     | 
    
         
            -
                  nil           => ['CalendarTypes',    '%s',            '_c:%s%s'           ]
         
     | 
| 
       32 
     | 
    
         
            -
                }
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                # @private
         
     | 
| 
       35 
     | 
    
         
            -
                ConstList = []
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                # private
         
     | 
| 
       38 
     | 
    
         
            -
                IRIHeader = /\A[_a-z\d]+:[^:]/i
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                # @private
         
     | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                   
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                     
     | 
| 
       66 
     | 
    
         
            -
                     
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                   
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                   
     | 
| 
       74 
     | 
    
         
            -
                   
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                   
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
       79 
     | 
    
         
            -
                     
     | 
| 
       80 
     | 
    
         
            -
                     
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                           
     | 
| 
       97 
     | 
    
         
            -
                           
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                     
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
                   
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                   
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
                   
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
                  #  
     | 
| 
       144 
     | 
    
         
            -
                  #
         
     | 
| 
       145 
     | 
    
         
            -
                  # 
     | 
| 
       146 
     | 
    
         
            -
                  #
         
     | 
| 
       147 
     | 
    
         
            -
                  # 
     | 
| 
       148 
     | 
    
         
            -
                  #
         
     | 
| 
       149 
     | 
    
         
            -
                   
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
                     
     | 
| 
       152 
     | 
    
         
            -
                     
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
                   
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
                   
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
                  #  
     | 
| 
       178 
     | 
    
         
            -
                   
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
                   
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
                  # @ 
     | 
| 
       183 
     | 
    
         
            -
                   
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
                    @_pool
         
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                  #
         
     | 
| 
       195 
     | 
    
         
            -
                   
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                   
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
                   
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
                   
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
                   
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
                   
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
                  #
         
     | 
| 
       214 
     | 
    
         
            -
                  # 
     | 
| 
       215 
     | 
    
         
            -
                  #
         
     | 
| 
       216 
     | 
    
         
            -
                  # 
     | 
| 
       217 
     | 
    
         
            -
                  def  
     | 
| 
       218 
     | 
    
         
            -
                     
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
                   
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
                   
     | 
| 
       241 
     | 
    
         
            -
             
     | 
| 
       242 
     | 
    
         
            -
                  # @ 
     | 
| 
       243 
     | 
    
         
            -
                   
     | 
| 
       244 
     | 
    
         
            -
                   
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
                  # 
     | 
| 
       247 
     | 
    
         
            -
                  #
         
     | 
| 
       248 
     | 
    
         
            -
                   
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
                      ' 
     | 
| 
       264 
     | 
    
         
            -
                      ' 
     | 
| 
       265 
     | 
    
         
            -
                      ' 
     | 
| 
       266 
     | 
    
         
            -
                      ' 
     | 
| 
       267 
     | 
    
         
            -
                      ' 
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
                       
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
                       
     | 
| 
       279 
     | 
    
         
            -
                       
     | 
| 
       280 
     | 
    
         
            -
                     
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
             
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
       293 
     | 
    
         
            -
                   
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
       295 
     | 
    
         
            -
                  #
         
     | 
| 
       296 
     | 
    
         
            -
                  # 
     | 
| 
       297 
     | 
    
         
            -
                  # @ 
     | 
| 
       298 
     | 
    
         
            -
                  # 
     | 
| 
       299 
     | 
    
         
            -
                   
     | 
| 
       300 
     | 
    
         
            -
             
     | 
| 
       301 
     | 
    
         
            -
                   
     | 
| 
       302 
     | 
    
         
            -
             
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
       307 
     | 
    
         
            -
             
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
             
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
             
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
                     
     | 
| 
       316 
     | 
    
         
            -
             
     | 
| 
       317 
     | 
    
         
            -
                     
     | 
| 
       318 
     | 
    
         
            -
                     
     | 
| 
       319 
     | 
    
         
            -
                     
     | 
| 
       320 
     | 
    
         
            -
                     
     | 
| 
       321 
     | 
    
         
            -
                       
     | 
| 
       322 
     | 
    
         
            -
                    end
         
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
                    #  
     | 
| 
       325 
     | 
    
         
            -
                    iri =  
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
                     
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
     | 
    
         
            -
             
     | 
| 
       340 
     | 
    
         
            -
                       
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
     | 
    
         
            -
             
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
             
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
       349 
     | 
    
         
            -
             
     | 
| 
       350 
     | 
    
         
            -
             
     | 
| 
       351 
     | 
    
         
            -
             
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
             
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
             
     | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
             
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
             
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
                     
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
             
     | 
| 
       365 
     | 
    
         
            -
                   
     | 
| 
       366 
     | 
    
         
            -
             
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
                     
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
       371 
     | 
    
         
            -
             
     | 
| 
       372 
     | 
    
         
            -
                     
     | 
| 
       373 
     | 
    
         
            -
                     
     | 
| 
       374 
     | 
    
         
            -
             
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
       376 
     | 
    
         
            -
             
     | 
| 
       377 
     | 
    
         
            -
             
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
       379 
     | 
    
         
            -
             
     | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
       382 
     | 
    
         
            -
             
     | 
| 
       383 
     | 
    
         
            -
             
     | 
| 
       384 
     | 
    
         
            -
                     
     | 
| 
       385 
     | 
    
         
            -
             
     | 
| 
       386 
     | 
    
         
            -
                     
     | 
| 
       387 
     | 
    
         
            -
                     
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
       390 
     | 
    
         
            -
             
     | 
| 
       391 
     | 
    
         
            -
             
     | 
| 
       392 
     | 
    
         
            -
             
     | 
| 
       393 
     | 
    
         
            -
             
     | 
| 
       394 
     | 
    
         
            -
             
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
             
     | 
| 
       397 
     | 
    
         
            -
                       
     | 
| 
       398 
     | 
    
         
            -
             
     | 
| 
       399 
     | 
    
         
            -
                     
     | 
| 
       400 
     | 
    
         
            -
             
     | 
| 
       401 
     | 
    
         
            -
             
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
             
     | 
| 
       404 
     | 
    
         
            -
                     
     | 
| 
       405 
     | 
    
         
            -
             
     | 
| 
       406 
     | 
    
         
            -
             
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
       409 
     | 
    
         
            -
             
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
                       
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
             
     | 
| 
       416 
     | 
    
         
            -
             
     | 
| 
       417 
     | 
    
         
            -
             
     | 
| 
       418 
     | 
    
         
            -
             
     | 
| 
       419 
     | 
    
         
            -
             
     | 
| 
       420 
     | 
    
         
            -
             
     | 
| 
       421 
     | 
    
         
            -
             
     | 
| 
       422 
     | 
    
         
            -
             
     | 
| 
       423 
     | 
    
         
            -
             
     | 
| 
       424 
     | 
    
         
            -
             
     | 
| 
       425 
     | 
    
         
            -
                      target
         
     | 
| 
       426 
     | 
    
         
            -
             
     | 
| 
       427 
     | 
    
         
            -
             
     | 
| 
       428 
     | 
    
         
            -
             
     | 
| 
       429 
     | 
    
         
            -
             
     | 
| 
       430 
     | 
    
         
            -
             
     | 
| 
       431 
     | 
    
         
            -
             
     | 
| 
       432 
     | 
    
         
            -
             
     | 
| 
       433 
     | 
    
         
            -
             
     | 
| 
       434 
     | 
    
         
            -
             
     | 
| 
       435 
     | 
    
         
            -
             
     | 
| 
       436 
     | 
    
         
            -
             
     | 
| 
       437 
     | 
    
         
            -
                       
     | 
| 
       438 
     | 
    
         
            -
             
     | 
| 
       439 
     | 
    
         
            -
                       
     | 
| 
       440 
     | 
    
         
            -
             
     | 
| 
       441 
     | 
    
         
            -
             
     | 
| 
       442 
     | 
    
         
            -
             
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
       444 
     | 
    
         
            -
                   
     | 
| 
       445 
     | 
    
         
            -
             
     | 
| 
       446 
     | 
    
         
            -
             
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
                     
     | 
| 
       449 
     | 
    
         
            -
             
     | 
| 
       450 
     | 
    
         
            -
             
     | 
| 
       451 
     | 
    
         
            -
             
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
       453 
     | 
    
         
            -
             
     | 
| 
       454 
     | 
    
         
            -
             
     | 
| 
       455 
     | 
    
         
            -
             
     | 
| 
       456 
     | 
    
         
            -
             
     | 
| 
       457 
     | 
    
         
            -
             
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
             
     | 
| 
       460 
     | 
    
         
            -
             
     | 
| 
       461 
     | 
    
         
            -
             
     | 
| 
       462 
     | 
    
         
            -
             
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
             
     | 
| 
       465 
     | 
    
         
            -
             
     | 
| 
       466 
     | 
    
         
            -
             
     | 
| 
       467 
     | 
    
         
            -
             
     | 
| 
       468 
     | 
    
         
            -
             
     | 
| 
       469 
     | 
    
         
            -
             
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
             
     | 
| 
       472 
     | 
    
         
            -
                   
     | 
| 
       473 
     | 
    
         
            -
             
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
       475 
     | 
    
         
            -
             
     | 
| 
       476 
     | 
    
         
            -
                     
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
             
     | 
| 
       479 
     | 
    
         
            -
             
     | 
| 
       480 
     | 
    
         
            -
             
     | 
| 
       481 
     | 
    
         
            -
             
     | 
| 
       482 
     | 
    
         
            -
             
     | 
| 
       483 
     | 
    
         
            -
             
     | 
| 
       484 
     | 
    
         
            -
             
     | 
| 
       485 
     | 
    
         
            -
                     
     | 
| 
       486 
     | 
    
         
            -
                    options 
     | 
| 
       487 
     | 
    
         
            -
             
     | 
| 
       488 
     | 
    
         
            -
                     
     | 
| 
       489 
     | 
    
         
            -
             
     | 
| 
       490 
     | 
    
         
            -
             
     | 
| 
       491 
     | 
    
         
            -
             
     | 
| 
       492 
     | 
    
         
            -
             
     | 
| 
       493 
     | 
    
         
            -
                       
     | 
| 
       494 
     | 
    
         
            -
             
     | 
| 
       495 
     | 
    
         
            -
                         
     | 
| 
       496 
     | 
    
         
            -
             
     | 
| 
       497 
     | 
    
         
            -
             
     | 
| 
       498 
     | 
    
         
            -
                     
     | 
| 
       499 
     | 
    
         
            -
             
     | 
| 
       500 
     | 
    
         
            -
                    #  
     | 
| 
       501 
     | 
    
         
            -
                     
     | 
| 
       502 
     | 
    
         
            -
                       
     | 
| 
       503 
     | 
    
         
            -
                       
     | 
| 
       504 
     | 
    
         
            -
             
     | 
| 
       505 
     | 
    
         
            -
                       
     | 
| 
       506 
     | 
    
         
            -
             
     | 
| 
       507 
     | 
    
         
            -
             
     | 
| 
       508 
     | 
    
         
            -
                         
     | 
| 
       509 
     | 
    
         
            -
             
     | 
| 
       510 
     | 
    
         
            -
             
     | 
| 
       511 
     | 
    
         
            -
             
     | 
| 
       512 
     | 
    
         
            -
             
     | 
| 
       513 
     | 
    
         
            -
             
     | 
| 
       514 
     | 
    
         
            -
             
     | 
| 
       515 
     | 
    
         
            -
             
     | 
| 
       516 
     | 
    
         
            -
             
     | 
| 
       517 
     | 
    
         
            -
             
     | 
| 
       518 
     | 
    
         
            -
             
     | 
| 
       519 
     | 
    
         
            -
             
     | 
| 
       520 
     | 
    
         
            -
             
     | 
| 
       521 
     | 
    
         
            -
             
     | 
| 
       522 
     | 
    
         
            -
             
     | 
| 
       523 
     | 
    
         
            -
             
     | 
| 
       524 
     | 
    
         
            -
             
     | 
| 
       525 
     | 
    
         
            -
             
     | 
| 
       526 
     | 
    
         
            -
             
     | 
| 
       527 
     | 
    
         
            -
             
     | 
| 
       528 
     | 
    
         
            -
             
     | 
| 
       529 
     | 
    
         
            -
             
     | 
| 
       530 
     | 
    
         
            -
             
     | 
| 
       531 
     | 
    
         
            -
             
     | 
| 
       532 
     | 
    
         
            -
             
     | 
| 
       533 
     | 
    
         
            -
             
     | 
| 
       534 
     | 
    
         
            -
             
     | 
| 
       535 
     | 
    
         
            -
             
     | 
| 
       536 
     | 
    
         
            -
             
     | 
| 
       537 
     | 
    
         
            -
             
     | 
| 
       538 
     | 
    
         
            -
             
     | 
| 
       539 
     | 
    
         
            -
             
     | 
| 
       540 
     | 
    
         
            -
             
     | 
| 
       541 
     | 
    
         
            -
             
     | 
| 
       542 
     | 
    
         
            -
                   
     | 
| 
       543 
     | 
    
         
            -
             
     | 
| 
       544 
     | 
    
         
            -
                     
     | 
| 
       545 
     | 
    
         
            -
                       
     | 
| 
       546 
     | 
    
         
            -
             
     | 
| 
       547 
     | 
    
         
            -
             
     | 
| 
       548 
     | 
    
         
            -
             
     | 
| 
       549 
     | 
    
         
            -
             
     | 
| 
       550 
     | 
    
         
            -
             
     | 
| 
       551 
     | 
    
         
            -
             
     | 
| 
       552 
     | 
    
         
            -
             
     | 
| 
       553 
     | 
    
         
            -
             
     | 
| 
       554 
     | 
    
         
            -
                   
     | 
| 
       555 
     | 
    
         
            -
             
     | 
| 
       556 
     | 
    
         
            -
             
     | 
| 
       557 
     | 
    
         
            -
             
     | 
| 
       558 
     | 
    
         
            -
             
     | 
| 
       559 
     | 
    
         
            -
             
     | 
| 
       560 
     | 
    
         
            -
             
     | 
| 
       561 
     | 
    
         
            -
             
     | 
| 
       562 
     | 
    
         
            -
             
     | 
| 
       563 
     | 
    
         
            -
                       
     | 
| 
       564 
     | 
    
         
            -
             
     | 
| 
       565 
     | 
    
         
            -
             
     | 
| 
       566 
     | 
    
         
            -
             
     | 
| 
       567 
     | 
    
         
            -
             
     | 
| 
       568 
     | 
    
         
            -
             
     | 
| 
       569 
     | 
    
         
            -
             
     | 
| 
       570 
     | 
    
         
            -
             
     | 
| 
       571 
     | 
    
         
            -
             
     | 
| 
       572 
     | 
    
         
            -
             
     | 
| 
       573 
     | 
    
         
            -
             
     | 
| 
       574 
     | 
    
         
            -
             
     | 
| 
       575 
     | 
    
         
            -
             
     | 
| 
       576 
     | 
    
         
            -
             
     | 
| 
       577 
     | 
    
         
            -
             
     | 
| 
       578 
     | 
    
         
            -
             
     | 
| 
       579 
     | 
    
         
            -
                         
     | 
| 
       580 
     | 
    
         
            -
             
     | 
| 
       581 
     | 
    
         
            -
             
     | 
| 
       582 
     | 
    
         
            -
             
     | 
| 
       583 
     | 
    
         
            -
                         
     | 
| 
       584 
     | 
    
         
            -
             
     | 
| 
       585 
     | 
    
         
            -
             
     | 
| 
       586 
     | 
    
         
            -
             
     | 
| 
       587 
     | 
    
         
            -
             
     | 
| 
       588 
     | 
    
         
            -
             
     | 
| 
       589 
     | 
    
         
            -
             
     | 
| 
       590 
     | 
    
         
            -
             
     | 
| 
       591 
     | 
    
         
            -
             
     | 
| 
       592 
     | 
    
         
            -
             
     | 
| 
       593 
     | 
    
         
            -
             
     | 
| 
       594 
     | 
    
         
            -
             
     | 
| 
       595 
     | 
    
         
            -
             
     | 
| 
       596 
     | 
    
         
            -
                       
     | 
| 
       597 
     | 
    
         
            -
                       
     | 
| 
       598 
     | 
    
         
            -
                       
     | 
| 
       599 
     | 
    
         
            -
             
     | 
| 
       600 
     | 
    
         
            -
             
     | 
| 
       601 
     | 
    
         
            -
                     
     | 
| 
       602 
     | 
    
         
            -
             
     | 
| 
       603 
     | 
    
         
            -
             
     | 
| 
       604 
     | 
    
         
            -
             
     | 
| 
       605 
     | 
    
         
            -
             
     | 
| 
       606 
     | 
    
         
            -
             
     | 
| 
       607 
     | 
    
         
            -
             
     | 
| 
       608 
     | 
    
         
            -
             
     | 
| 
       609 
     | 
    
         
            -
             
     | 
| 
       610 
     | 
    
         
            -
             
     | 
| 
       611 
     | 
    
         
            -
             
     | 
| 
       612 
     | 
    
         
            -
             
     | 
| 
       613 
     | 
    
         
            -
             
     | 
| 
       614 
     | 
    
         
            -
             
     | 
| 
       615 
     | 
    
         
            -
             
     | 
| 
       616 
     | 
    
         
            -
             
     | 
| 
       617 
     | 
    
         
            -
             
     | 
| 
       618 
     | 
    
         
            -
             
     | 
| 
       619 
     | 
    
         
            -
             
     | 
| 
       620 
     | 
    
         
            -
             
     | 
| 
       621 
     | 
    
         
            -
             
     | 
| 
       622 
     | 
    
         
            -
             
     | 
| 
       623 
     | 
    
         
            -
             
     | 
| 
       624 
     | 
    
         
            -
             
     | 
| 
       625 
     | 
    
         
            -
             
     | 
| 
       626 
     | 
    
         
            -
                       
     | 
| 
       627 
     | 
    
         
            -
             
     | 
| 
       628 
     | 
    
         
            -
             
     | 
| 
       629 
     | 
    
         
            -
             
     | 
| 
       630 
     | 
    
         
            -
             
     | 
| 
       631 
     | 
    
         
            -
             
     | 
| 
       632 
     | 
    
         
            -
             
     | 
| 
       633 
     | 
    
         
            -
             
     | 
| 
       634 
     | 
    
         
            -
             
     | 
| 
       635 
     | 
    
         
            -
             
     | 
| 
       636 
     | 
    
         
            -
             
     | 
| 
       637 
     | 
    
         
            -
             
     | 
| 
       638 
     | 
    
         
            -
             
     | 
| 
       639 
     | 
    
         
            -
                         
     | 
| 
       640 
     | 
    
         
            -
             
     | 
| 
       641 
     | 
    
         
            -
             
     | 
| 
       642 
     | 
    
         
            -
             
     | 
| 
       643 
     | 
    
         
            -
                         
     | 
| 
       644 
     | 
    
         
            -
                           
     | 
| 
       645 
     | 
    
         
            -
             
     | 
| 
       646 
     | 
    
         
            -
             
     | 
| 
       647 
     | 
    
         
            -
             
     | 
| 
       648 
     | 
    
         
            -
                         
     | 
| 
       649 
     | 
    
         
            -
             
     | 
| 
       650 
     | 
    
         
            -
             
     | 
| 
       651 
     | 
    
         
            -
             
     | 
| 
       652 
     | 
    
         
            -
             
     | 
| 
       653 
     | 
    
         
            -
             
     | 
| 
       654 
     | 
    
         
            -
             
     | 
| 
       655 
     | 
    
         
            -
             
     | 
| 
       656 
     | 
    
         
            -
             
     | 
| 
       657 
     | 
    
         
            -
             
     | 
| 
       658 
     | 
    
         
            -
             
     | 
| 
       659 
     | 
    
         
            -
             
     | 
| 
       660 
     | 
    
         
            -
             
     | 
| 
       661 
     | 
    
         
            -
                       
     | 
| 
       662 
     | 
    
         
            -
             
     | 
| 
       663 
     | 
    
         
            -
                     
     | 
| 
       664 
     | 
    
         
            -
             
     | 
| 
       665 
     | 
    
         
            -
             
     | 
| 
       666 
     | 
    
         
            -
             
     | 
| 
       667 
     | 
    
         
            -
             
     | 
| 
       668 
     | 
    
         
            -
             
     | 
| 
       669 
     | 
    
         
            -
             
     | 
| 
       670 
     | 
    
         
            -
             
     | 
| 
       671 
     | 
    
         
            -
             
     | 
| 
       672 
     | 
    
         
            -
             
     | 
| 
       673 
     | 
    
         
            -
             
     | 
| 
       674 
     | 
    
         
            -
             
     | 
| 
       675 
     | 
    
         
            -
             
     | 
| 
       676 
     | 
    
         
            -
             
     | 
| 
       677 
     | 
    
         
            -
             
     | 
| 
       678 
     | 
    
         
            -
             
     | 
| 
       679 
     | 
    
         
            -
             
     | 
| 
       680 
     | 
    
         
            -
             
     | 
| 
       681 
     | 
    
         
            -
             
     | 
| 
       682 
     | 
    
         
            -
             
     | 
| 
       683 
     | 
    
         
            -
             
     | 
| 
       684 
     | 
    
         
            -
             
     | 
| 
       685 
     | 
    
         
            -
             
     | 
| 
       686 
     | 
    
         
            -
                 
     | 
| 
       687 
     | 
    
         
            -
             
     | 
| 
       688 
     | 
    
         
            -
                 
     | 
| 
       689 
     | 
    
         
            -
             
     | 
| 
       690 
     | 
    
         
            -
                #
         
     | 
| 
       691 
     | 
    
         
            -
                 
     | 
| 
       692 
     | 
    
         
            -
             
     | 
| 
       693 
     | 
    
         
            -
                # 
     | 
| 
       694 
     | 
    
         
            -
                #
         
     | 
| 
       695 
     | 
    
         
            -
                # @return [ 
     | 
| 
       696 
     | 
    
         
            -
                #
         
     | 
| 
       697 
     | 
    
         
            -
                 
     | 
| 
       698 
     | 
    
         
            -
             
     | 
| 
       699 
     | 
    
         
            -
             
     | 
| 
       700 
     | 
    
         
            -
                # 
     | 
| 
       701 
     | 
    
         
            -
                #
         
     | 
| 
       702 
     | 
    
         
            -
                # 
     | 
| 
       703 
     | 
    
         
            -
                #    
     | 
| 
       704 
     | 
    
         
            -
                #
         
     | 
| 
       705 
     | 
    
         
            -
                #  
     | 
| 
       706 
     | 
    
         
            -
                #
         
     | 
| 
       707 
     | 
    
         
            -
                 
     | 
| 
       708 
     | 
    
         
            -
             
     | 
| 
       709 
     | 
    
         
            -
                 
     | 
| 
       710 
     | 
    
         
            -
             
     | 
| 
       711 
     | 
    
         
            -
                # 
     | 
| 
       712 
     | 
    
         
            -
                #
         
     | 
| 
       713 
     | 
    
         
            -
                 
     | 
| 
       714 
     | 
    
         
            -
             
     | 
| 
       715 
     | 
    
         
            -
                #  
     | 
| 
       716 
     | 
    
         
            -
                #
         
     | 
| 
       717 
     | 
    
         
            -
                # @ 
     | 
| 
       718 
     | 
    
         
            -
                #
         
     | 
| 
       719 
     | 
    
         
            -
                 
     | 
| 
       720 
     | 
    
         
            -
             
     | 
| 
       721 
     | 
    
         
            -
                 
     | 
| 
       722 
     | 
    
         
            -
             
     | 
| 
       723 
     | 
    
         
            -
             
     | 
| 
       724 
     | 
    
         
            -
             
     | 
| 
       725 
     | 
    
         
            -
             
     | 
| 
       726 
     | 
    
         
            -
             
     | 
| 
       727 
     | 
    
         
            -
             
     | 
| 
       728 
     | 
    
         
            -
             
     | 
| 
       729 
     | 
    
         
            -
             
     | 
| 
       730 
     | 
    
         
            -
             
     | 
| 
       731 
     | 
    
         
            -
             
     | 
| 
       732 
     | 
    
         
            -
                 
     | 
| 
       733 
     | 
    
         
            -
             
     | 
| 
       734 
     | 
    
         
            -
             
     | 
| 
       735 
     | 
    
         
            -
             
     | 
| 
       736 
     | 
    
         
            -
             
     | 
| 
       737 
     | 
    
         
            -
             
     | 
| 
       738 
     | 
    
         
            -
             
     | 
| 
       739 
     | 
    
         
            -
             
     | 
| 
       740 
     | 
    
         
            -
             
     | 
| 
       741 
     | 
    
         
            -
             
     | 
| 
       742 
     | 
    
         
            -
                   
     | 
| 
       743 
     | 
    
         
            -
                   
     | 
| 
       744 
     | 
    
         
            -
             
     | 
| 
       745 
     | 
    
         
            -
             
     | 
| 
       746 
     | 
    
         
            -
             
     | 
| 
       747 
     | 
    
         
            -
             
     | 
| 
       748 
     | 
    
         
            -
             
     | 
| 
       749 
     | 
    
         
            -
             
     | 
| 
       750 
     | 
    
         
            -
             
     | 
| 
       751 
     | 
    
         
            -
             
     | 
| 
       752 
     | 
    
         
            -
             
     | 
| 
       753 
     | 
    
         
            -
             
     | 
| 
       754 
     | 
    
         
            -
             
     | 
| 
       755 
     | 
    
         
            -
             
     | 
| 
       756 
     | 
    
         
            -
             
     | 
| 
       757 
     | 
    
         
            -
             
     | 
| 
       758 
     | 
    
         
            -
             
     | 
| 
       759 
     | 
    
         
            -
                     
     | 
| 
       760 
     | 
    
         
            -
             
     | 
| 
       761 
     | 
    
         
            -
             
     | 
| 
       762 
     | 
    
         
            -
             
     | 
| 
       763 
     | 
    
         
            -
             
     | 
| 
       764 
     | 
    
         
            -
             
     | 
| 
       765 
     | 
    
         
            -
             
     | 
| 
       766 
     | 
    
         
            -
             
     | 
| 
       767 
     | 
    
         
            -
             
     | 
| 
       768 
     | 
    
         
            -
             
     | 
| 
       769 
     | 
    
         
            -
             
     | 
| 
       770 
     | 
    
         
            -
             
     | 
| 
       771 
     | 
    
         
            -
             
     | 
| 
       772 
     | 
    
         
            -
             
     | 
| 
       773 
     | 
    
         
            -
             
     | 
| 
       774 
     | 
    
         
            -
             
     | 
| 
       775 
     | 
    
         
            -
             
     | 
| 
       776 
     | 
    
         
            -
             
     | 
| 
       777 
     | 
    
         
            -
                 
     | 
| 
       778 
     | 
    
         
            -
             
     | 
| 
       779 
     | 
    
         
            -
                #  
     | 
| 
       780 
     | 
    
         
            -
                #
         
     | 
| 
       781 
     | 
    
         
            -
                 
     | 
| 
       782 
     | 
    
         
            -
             
     | 
| 
       783 
     | 
    
         
            -
             
     | 
| 
       784 
     | 
    
         
            -
                   
     | 
| 
       785 
     | 
    
         
            -
             
     | 
| 
       786 
     | 
    
         
            -
             
     | 
| 
       787 
     | 
    
         
            -
             
     | 
| 
       788 
     | 
    
         
            -
             
     | 
| 
       789 
     | 
    
         
            -
                 
     | 
| 
       790 
     | 
    
         
            -
             
     | 
| 
       791 
     | 
    
         
            -
                #  
     | 
| 
       792 
     | 
    
         
            -
                #
         
     | 
| 
       793 
     | 
    
         
            -
                 
     | 
| 
       794 
     | 
    
         
            -
             
     | 
| 
       795 
     | 
    
         
            -
                 
     | 
| 
       796 
     | 
    
         
            -
             
     | 
| 
       797 
     | 
    
         
            -
             
     | 
| 
       798 
     | 
    
         
            -
             
     | 
| 
       799 
     | 
    
         
            -
                   
     | 
| 
       800 
     | 
    
         
            -
             
     | 
| 
       801 
     | 
    
         
            -
             
     | 
| 
       802 
     | 
    
         
            -
             
     | 
| 
       803 
     | 
    
         
            -
             
     | 
| 
       804 
     | 
    
         
            -
                 
     | 
| 
       805 
     | 
    
         
            -
             
     | 
| 
       806 
     | 
    
         
            -
                #  
     | 
| 
       807 
     | 
    
         
            -
                #
         
     | 
| 
       808 
     | 
    
         
            -
                # 
     | 
| 
       809 
     | 
    
         
            -
                 
     | 
| 
       810 
     | 
    
         
            -
             
     | 
| 
       811 
     | 
    
         
            -
             
     | 
| 
       812 
     | 
    
         
            -
             
     | 
| 
       813 
     | 
    
         
            -
             
     | 
| 
       814 
     | 
    
         
            -
             
     | 
| 
       815 
     | 
    
         
            -
             
     | 
| 
       816 
     | 
    
         
            -
                 
     | 
| 
       817 
     | 
    
         
            -
             
     | 
| 
       818 
     | 
    
         
            -
                #  
     | 
| 
       819 
     | 
    
         
            -
                #
         
     | 
| 
       820 
     | 
    
         
            -
                 
     | 
| 
       821 
     | 
    
         
            -
             
     | 
| 
       822 
     | 
    
         
            -
             
     | 
| 
       823 
     | 
    
         
            -
             
     | 
| 
       824 
     | 
    
         
            -
             
     | 
| 
       825 
     | 
    
         
            -
                   
     | 
| 
       826 
     | 
    
         
            -
                end
         
     | 
| 
       827 
     | 
    
         
            -
             
     | 
| 
       828 
     | 
    
         
            -
                #  
     | 
| 
       829 
     | 
    
         
            -
                #
         
     | 
| 
       830 
     | 
    
         
            -
                # @return [When::Parts::Resource]
         
     | 
| 
       831 
     | 
    
         
            -
                #
         
     | 
| 
       832 
     | 
    
         
            -
                def  
     | 
| 
       833 
     | 
    
         
            -
                  c = self
         
     | 
| 
       834 
     | 
    
         
            -
                  c = c.child[0] while c.child && c.child.size > 0
         
     | 
| 
       835 
     | 
    
         
            -
                  c._pool[' 
     | 
| 
       836 
     | 
    
         
            -
             
     | 
| 
       837 
     | 
    
         
            -
             
     | 
| 
       838 
     | 
    
         
            -
             
     | 
| 
       839 
     | 
    
         
            -
             
     | 
| 
       840 
     | 
    
         
            -
                #
         
     | 
| 
       841 
     | 
    
         
            -
                # 
     | 
| 
       842 
     | 
    
         
            -
                # 
     | 
| 
       843 
     | 
    
         
            -
                # 
     | 
| 
       844 
     | 
    
         
            -
                 
     | 
| 
       845 
     | 
    
         
            -
             
     | 
| 
       846 
     | 
    
         
            -
                   
     | 
| 
       847 
     | 
    
         
            -
             
     | 
| 
       848 
     | 
    
         
            -
             
     | 
| 
       849 
     | 
    
         
            -
                 
     | 
| 
       850 
     | 
    
         
            -
             
     | 
| 
       851 
     | 
    
         
            -
                #  
     | 
| 
       852 
     | 
    
         
            -
                # 
     | 
| 
       853 
     | 
    
         
            -
                # 
     | 
| 
       854 
     | 
    
         
            -
                #
         
     | 
| 
       855 
     | 
    
         
            -
                 
     | 
| 
       856 
     | 
    
         
            -
             
     | 
| 
       857 
     | 
    
         
            -
             
     | 
| 
       858 
     | 
    
         
            -
             
     | 
| 
       859 
     | 
    
         
            -
             
     | 
| 
       860 
     | 
    
         
            -
             
     | 
| 
       861 
     | 
    
         
            -
             
     | 
| 
       862 
     | 
    
         
            -
             
     | 
| 
       863 
     | 
    
         
            -
                 
     | 
| 
       864 
     | 
    
         
            -
             
     | 
| 
       865 
     | 
    
         
            -
                #  
     | 
| 
       866 
     | 
    
         
            -
                #
         
     | 
| 
       867 
     | 
    
         
            -
                 
     | 
| 
       868 
     | 
    
         
            -
             
     | 
| 
       869 
     | 
    
         
            -
             
     | 
| 
       870 
     | 
    
         
            -
             
     | 
| 
       871 
     | 
    
         
            -
             
     | 
| 
       872 
     | 
    
         
            -
             
     | 
| 
       873 
     | 
    
         
            -
             
     | 
| 
       874 
     | 
    
         
            -
             
     | 
| 
       875 
     | 
    
         
            -
                 
     | 
| 
       876 
     | 
    
         
            -
             
     | 
| 
       877 
     | 
    
         
            -
             
     | 
| 
       878 
     | 
    
         
            -
             
     | 
| 
       879 
     | 
    
         
            -
             
     | 
| 
       880 
     | 
    
         
            -
             
     | 
| 
       881 
     | 
    
         
            -
             
     | 
| 
       882 
     | 
    
         
            -
             
     | 
| 
       883 
     | 
    
         
            -
             
     | 
| 
       884 
     | 
    
         
            -
             
     | 
| 
       885 
     | 
    
         
            -
                 
     | 
| 
       886 
     | 
    
         
            -
             
     | 
| 
       887 
     | 
    
         
            -
                # 
     | 
| 
       888 
     | 
    
         
            -
                 
     | 
| 
       889 
     | 
    
         
            -
             
     | 
| 
       890 
     | 
    
         
            -
                   
     | 
| 
       891 
     | 
    
         
            -
             
     | 
| 
       892 
     | 
    
         
            -
             
     | 
| 
       893 
     | 
    
         
            -
             
     | 
| 
       894 
     | 
    
         
            -
             
     | 
| 
       895 
     | 
    
         
            -
             
     | 
| 
       896 
     | 
    
         
            -
             
     | 
| 
       897 
     | 
    
         
            -
                 
     | 
| 
       898 
     | 
    
         
            -
             
     | 
| 
       899 
     | 
    
         
            -
                #
         
     | 
| 
       900 
     | 
    
         
            -
                 
     | 
| 
       901 
     | 
    
         
            -
             
     | 
| 
       902 
     | 
    
         
            -
             
     | 
| 
       903 
     | 
    
         
            -
             
     | 
| 
       904 
     | 
    
         
            -
                 
     | 
| 
       905 
     | 
    
         
            -
             
     | 
| 
       906 
     | 
    
         
            -
                #  
     | 
| 
       907 
     | 
    
         
            -
                # 
     | 
| 
       908 
     | 
    
         
            -
                #
         
     | 
| 
       909 
     | 
    
         
            -
                # 
     | 
| 
       910 
     | 
    
         
            -
                #
         
     | 
| 
       911 
     | 
    
         
            -
                 
     | 
| 
       912 
     | 
    
         
            -
             
     | 
| 
       913 
     | 
    
         
            -
                  return  
     | 
| 
       914 
     | 
    
         
            -
             
     | 
| 
       915 
     | 
    
         
            -
             
     | 
| 
       916 
     | 
    
         
            -
             
     | 
| 
       917 
     | 
    
         
            -
                # 
     | 
| 
       918 
     | 
    
         
            -
                #
         
     | 
| 
       919 
     | 
    
         
            -
                #  
     | 
| 
       920 
     | 
    
         
            -
                #
         
     | 
| 
       921 
     | 
    
         
            -
                # @ 
     | 
| 
       922 
     | 
    
         
            -
                #
         
     | 
| 
       923 
     | 
    
         
            -
                 
     | 
| 
       924 
     | 
    
         
            -
             
     | 
| 
       925 
     | 
    
         
            -
             
     | 
| 
       926 
     | 
    
         
            -
                   
     | 
| 
       927 
     | 
    
         
            -
                end
         
     | 
| 
       928 
     | 
    
         
            -
             
     | 
| 
       929 
     | 
    
         
            -
             
     | 
| 
       930 
     | 
    
         
            -
                 
     | 
| 
       931 
     | 
    
         
            -
             
     | 
| 
       932 
     | 
    
         
            -
                # 
     | 
| 
       933 
     | 
    
         
            -
                 
     | 
| 
       934 
     | 
    
         
            -
             
     | 
| 
       935 
     | 
    
         
            -
                 
     | 
| 
       936 
     | 
    
         
            -
             
     | 
| 
       937 
     | 
    
         
            -
                 
     | 
| 
       938 
     | 
    
         
            -
             
     | 
| 
       939 
     | 
    
         
            -
                 
     | 
| 
       940 
     | 
    
         
            -
                 
     | 
| 
       941 
     | 
    
         
            -
             
     | 
| 
       942 
     | 
    
         
            -
             
     | 
| 
       943 
     | 
    
         
            -
             
     | 
| 
       944 
     | 
    
         
            -
                 
     | 
| 
       945 
     | 
    
         
            -
             
     | 
| 
       946 
     | 
    
         
            -
             
     | 
| 
       947 
     | 
    
         
            -
                 
     | 
| 
       948 
     | 
    
         
            -
             
     | 
| 
       949 
     | 
    
         
            -
             
     | 
| 
       950 
     | 
    
         
            -
             
     | 
| 
       951 
     | 
    
         
            -
             
     | 
| 
       952 
     | 
    
         
            -
             
     | 
| 
       953 
     | 
    
         
            -
                   
     | 
| 
       954 
     | 
    
         
            -
             
     | 
| 
       955 
     | 
    
         
            -
                   
     | 
| 
       956 
     | 
    
         
            -
             
     | 
| 
       957 
     | 
    
         
            -
             
     | 
| 
       958 
     | 
    
         
            -
                 
     | 
| 
       959 
     | 
    
         
            -
             
     | 
| 
       960 
     | 
    
         
            -
             
     | 
| 
       961 
     | 
    
         
            -
             
     | 
| 
       962 
     | 
    
         
            -
                  @ 
     | 
| 
       963 
     | 
    
         
            -
             
     | 
| 
       964 
     | 
    
         
            -
             
     | 
| 
       965 
     | 
    
         
            -
             
     | 
| 
       966 
     | 
    
         
            -
             
     | 
| 
       967 
     | 
    
         
            -
             
     | 
| 
       968 
     | 
    
         
            -
             
     | 
| 
       969 
     | 
    
         
            -
             
     | 
| 
       970 
     | 
    
         
            -
             
     | 
| 
       971 
     | 
    
         
            -
             
     | 
| 
       972 
     | 
    
         
            -
                 
     | 
| 
       973 
     | 
    
         
            -
             
     | 
| 
       974 
     | 
    
         
            -
             
     | 
| 
       975 
     | 
    
         
            -
             
     | 
| 
       976 
     | 
    
         
            -
             
     | 
| 
       977 
     | 
    
         
            -
             
     | 
| 
       978 
     | 
    
         
            -
             
     | 
| 
       979 
     | 
    
         
            -
             
     | 
| 
       980 
     | 
    
         
            -
             
     | 
| 
       981 
     | 
    
         
            -
             
     | 
| 
       982 
     | 
    
         
            -
             
     | 
| 
       983 
     | 
    
         
            -
             
     | 
| 
       984 
     | 
    
         
            -
             
     | 
| 
       985 
     | 
    
         
            -
             
     | 
| 
       986 
     | 
    
         
            -
             
     | 
| 
       987 
     | 
    
         
            -
             
     | 
| 
       988 
     | 
    
         
            -
             
     | 
| 
       989 
     | 
    
         
            -
             
     | 
| 
       990 
     | 
    
         
            -
             
     | 
| 
       991 
     | 
    
         
            -
             
     | 
| 
       992 
     | 
    
         
            -
             
     | 
| 
       993 
     | 
    
         
            -
             
     | 
| 
       994 
     | 
    
         
            -
             
     | 
| 
       995 
     | 
    
         
            -
             
     | 
| 
       996 
     | 
    
         
            -
             
     | 
| 
       997 
     | 
    
         
            -
             
     | 
| 
       998 
     | 
    
         
            -
                     
     | 
| 
       999 
     | 
    
         
            -
             
     | 
| 
       1000 
     | 
    
         
            -
                     
     | 
| 
       1001 
     | 
    
         
            -
             
     | 
| 
       1002 
     | 
    
         
            -
             
     | 
| 
       1003 
     | 
    
         
            -
                     
     | 
| 
       1004 
     | 
    
         
            -
             
     | 
| 
       1005 
     | 
    
         
            -
             
     | 
| 
       1006 
     | 
    
         
            -
             
     | 
| 
       1007 
     | 
    
         
            -
             
     | 
| 
       1008 
     | 
    
         
            -
             
     | 
| 
       1009 
     | 
    
         
            -
             
     | 
| 
       1010 
     | 
    
         
            -
                     
     | 
| 
       1011 
     | 
    
         
            -
             
     | 
| 
       1012 
     | 
    
         
            -
                     
     | 
| 
       1013 
     | 
    
         
            -
                       
     | 
| 
       1014 
     | 
    
         
            -
             
     | 
| 
       1015 
     | 
    
         
            -
             
     | 
| 
       1016 
     | 
    
         
            -
             
     | 
| 
       1017 
     | 
    
         
            -
             
     | 
| 
       1018 
     | 
    
         
            -
                   
     | 
| 
       1019 
     | 
    
         
            -
             
     | 
| 
       1020 
     | 
    
         
            -
             
     | 
| 
       1021 
     | 
    
         
            -
             
     | 
| 
       1022 
     | 
    
         
            -
                     
     | 
| 
       1023 
     | 
    
         
            -
                    @ 
     | 
| 
       1024 
     | 
    
         
            -
             
     | 
| 
       1025 
     | 
    
         
            -
             
     | 
| 
       1026 
     | 
    
         
            -
             
     | 
| 
       1027 
     | 
    
         
            -
             
     | 
| 
       1028 
     | 
    
         
            -
             
     | 
| 
       1029 
     | 
    
         
            -
                     
     | 
| 
       1030 
     | 
    
         
            -
             
     | 
| 
       1031 
     | 
    
         
            -
             
     | 
| 
       1032 
     | 
    
         
            -
             
     | 
| 
       1033 
     | 
    
         
            -
             
     | 
| 
       1034 
     | 
    
         
            -
             
     | 
| 
       1035 
     | 
    
         
            -
             
     | 
| 
       1036 
     | 
    
         
            -
             
     | 
| 
       1037 
     | 
    
         
            -
             
     | 
| 
       1038 
     | 
    
         
            -
             
     | 
| 
       1039 
     | 
    
         
            -
             
     | 
| 
       1040 
     | 
    
         
            -
                     
     | 
| 
       1041 
     | 
    
         
            -
             
     | 
| 
       1042 
     | 
    
         
            -
                       
     | 
| 
       1043 
     | 
    
         
            -
             
     | 
| 
       1044 
     | 
    
         
            -
             
     | 
| 
       1045 
     | 
    
         
            -
             
     | 
| 
       1046 
     | 
    
         
            -
             
     | 
| 
       1047 
     | 
    
         
            -
             
     | 
| 
       1048 
     | 
    
         
            -
             
     | 
| 
       1049 
     | 
    
         
            -
             
     | 
| 
       1050 
     | 
    
         
            -
             
     | 
| 
       1051 
     | 
    
         
            -
             
     | 
| 
       1052 
     | 
    
         
            -
             
     | 
| 
       1053 
     | 
    
         
            -
             
     | 
| 
       1054 
     | 
    
         
            -
             
     | 
| 
       1055 
     | 
    
         
            -
                     
     | 
| 
       1056 
     | 
    
         
            -
             
     | 
| 
       1057 
     | 
    
         
            -
             
     | 
| 
       1058 
     | 
    
         
            -
             
     | 
| 
       1059 
     | 
    
         
            -
             
     | 
| 
       1060 
     | 
    
         
            -
             
     | 
| 
       1061 
     | 
    
         
            -
             
     | 
| 
       1062 
     | 
    
         
            -
             
     | 
| 
       1063 
     | 
    
         
            -
             
     | 
| 
       1064 
     | 
    
         
            -
             
     | 
| 
       1065 
     | 
    
         
            -
                   
     | 
| 
       1066 
     | 
    
         
            -
                   
     | 
| 
       1067 
     | 
    
         
            -
             
     | 
| 
       1068 
     | 
    
         
            -
             
     | 
| 
       1069 
     | 
    
         
            -
             
     | 
| 
       1070 
     | 
    
         
            -
             
     | 
| 
       1071 
     | 
    
         
            -
                   
     | 
| 
       1072 
     | 
    
         
            -
             
     | 
| 
       1073 
     | 
    
         
            -
             
     | 
| 
       1074 
     | 
    
         
            -
             
     | 
| 
       1075 
     | 
    
         
            -
                       
     | 
| 
       1076 
     | 
    
         
            -
             
     | 
| 
       1077 
     | 
    
         
            -
             
     | 
| 
       1078 
     | 
    
         
            -
             
     | 
| 
       1079 
     | 
    
         
            -
             
     | 
| 
       1080 
     | 
    
         
            -
             
     | 
| 
       1081 
     | 
    
         
            -
             
     | 
| 
       1082 
     | 
    
         
            -
             
     | 
| 
       1083 
     | 
    
         
            -
             
     | 
| 
       1084 
     | 
    
         
            -
                   
     | 
| 
       1085 
     | 
    
         
            -
             
     | 
| 
       1086 
     | 
    
         
            -
             
     | 
| 
       1087 
     | 
    
         
            -
             
     | 
| 
       1088 
     | 
    
         
            -
             
     | 
| 
       1089 
     | 
    
         
            -
             
     | 
| 
       1090 
     | 
    
         
            -
             
     | 
| 
       1091 
     | 
    
         
            -
             
     | 
| 
       1092 
     | 
    
         
            -
             
     | 
| 
       1093 
     | 
    
         
            -
             
     | 
| 
       1094 
     | 
    
         
            -
             
     | 
| 
       1095 
     | 
    
         
            -
             
     | 
| 
       1096 
     | 
    
         
            -
             
     | 
| 
       1097 
     | 
    
         
            -
             
     | 
| 
       1098 
     | 
    
         
            -
             
     | 
| 
       1099 
     | 
    
         
            -
             
     | 
| 
       1100 
     | 
    
         
            -
             
     | 
| 
       1101 
     | 
    
         
            -
                 
     | 
| 
       1102 
     | 
    
         
            -
             
     | 
| 
       1103 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 3 
     | 
    
         
            +
              Copyright (C) 2011-2015 Takashi SUGA
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
         
     | 
| 
      
 6 
     | 
    
         
            +
            =end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # 本ライブラリのための諸々の部品
         
     | 
| 
      
 10 
     | 
    
         
            +
            #
         
     | 
| 
      
 11 
     | 
    
         
            +
            module When::Parts
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              #
         
     | 
| 
      
 14 
     | 
    
         
            +
              # Resource which has 'International Resource Identifier'
         
     | 
| 
      
 15 
     | 
    
         
            +
              #
         
     | 
| 
      
 16 
     | 
    
         
            +
              module Resource
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 19 
     | 
    
         
            +
                LabelProperty = nil
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 22 
     | 
    
         
            +
                ConstTypes = {
         
     | 
| 
      
 23 
     | 
    
         
            +
                  'SolarTerms'  => ['CalendarNote',     '%sSolarTerms',  '_n:%sSolarTerms%s' ],
         
     | 
| 
      
 24 
     | 
    
         
            +
                  'LunarPhases' => ['LunarPhases',      '%sLunarPhases', '_n:%sLunarPhases%s'],
         
     | 
| 
      
 25 
     | 
    
         
            +
                  'Terms'       => ['BasicTypes::M17n', '%s',            '_m:%s%s'           ],
         
     | 
| 
      
 26 
     | 
    
         
            +
                  'Era'         => ['TM::CalendarEra',  '%s',            '_e:%s%s'           ],
         
     | 
| 
      
 27 
     | 
    
         
            +
                  'Residue'     => ['Coordinates',      '%s',            '_co:%s%s'          ],
         
     | 
| 
      
 28 
     | 
    
         
            +
                  'Week'        => ['CalendarNote',     '%sWeek',        '_n:%sWeek%s'       ],
         
     | 
| 
      
 29 
     | 
    
         
            +
                  'Note'        => ['CalendarNote',     '%s',            '_n:%s%s'           ],
         
     | 
| 
      
 30 
     | 
    
         
            +
                  'Notes'       => ['CalendarNote',     '%s',            '_n:%s/Notes%s'     ],
         
     | 
| 
      
 31 
     | 
    
         
            +
                  nil           => ['CalendarTypes',    '%s',            '_c:%s%s'           ]
         
     | 
| 
      
 32 
     | 
    
         
            +
                }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 35 
     | 
    
         
            +
                ConstList = []
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 38 
     | 
    
         
            +
                IRIHeader = /\A[_a-z\d]+:[^:]/i
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 41 
     | 
    
         
            +
                IRIEncodeTable = {'#'=>'%23', '<'=>'%3C', '>'=>'%3E', '{'=>'%7B', '}'=>'%7D'}
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 44 
     | 
    
         
            +
                IRIDecodeTable = IRIEncodeTable.invert
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 47 
     | 
    
         
            +
                IRIEncode = /[#{IRIEncodeTable.keys.join('')}]/
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 50 
     | 
    
         
            +
                IRIDecode = /#{IRIDecodeTable.keys.join('|')}/
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 53 
     | 
    
         
            +
                class ContentLine
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  RFC6350 = {
         
     | 
| 
      
 56 
     | 
    
         
            +
                    "\\\\" => "\\",
         
     | 
| 
      
 57 
     | 
    
         
            +
                    "\\n"  => "\n",
         
     | 
| 
      
 58 
     | 
    
         
            +
                    "\\N"  => "\n",
         
     | 
| 
      
 59 
     | 
    
         
            +
                    "\\;"  => ";",
         
     | 
| 
      
 60 
     | 
    
         
            +
                    "\\:"  => ":"
         
     | 
| 
      
 61 
     | 
    
         
            +
                  }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  RFC6868 = {
         
     | 
| 
      
 64 
     | 
    
         
            +
                    "^n"  => "\n",
         
     | 
| 
      
 65 
     | 
    
         
            +
                    "^^"  => "^",
         
     | 
| 
      
 66 
     | 
    
         
            +
                    "^'"  => '"'
         
     | 
| 
      
 67 
     | 
    
         
            +
                  }
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  attr_reader   :predicate
         
     | 
| 
      
 70 
     | 
    
         
            +
                  attr_accessor :object
         
     | 
| 
      
 71 
     | 
    
         
            +
                  attr_reader   :attribute
         
     | 
| 
      
 72 
     | 
    
         
            +
                  attr_accessor :namespace
         
     | 
| 
      
 73 
     | 
    
         
            +
                  attr_accessor :same_altid
         
     | 
| 
      
 74 
     | 
    
         
            +
                  attr_reader   :marked
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                  def initialize(key, object=nil, marked=nil)
         
     | 
| 
      
 77 
     | 
    
         
            +
                    key = key.downcase.gsub(/-/,'_') if (key==key.upcase)
         
     | 
| 
      
 78 
     | 
    
         
            +
                    @predicate, @namespace = key.split(/:/).reverse
         
     | 
| 
      
 79 
     | 
    
         
            +
                    object     = object.gsub(/\^./) {|escape| RFC6868[escape] || escape} if object.instance_of?(String)
         
     | 
| 
      
 80 
     | 
    
         
            +
                    @object    = object
         
     | 
| 
      
 81 
     | 
    
         
            +
                    @marked    = marked
         
     | 
| 
      
 82 
     | 
    
         
            +
                    @attribute = {}
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                  #
         
     | 
| 
      
 86 
     | 
    
         
            +
                  # 行から RFC5545 の Property を取り出す
         
     | 
| 
      
 87 
     | 
    
         
            +
                  #
         
     | 
| 
      
 88 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 89 
     | 
    
         
            +
                  def self.extract_rfc5545_Property(specification, options)
         
     | 
| 
      
 90 
     | 
    
         
            +
                    return specification unless specification =~ /\A[-A-Z_]+=.+?:/i
         
     | 
| 
      
 91 
     | 
    
         
            +
                    caret = 0
         
     | 
| 
      
 92 
     | 
    
         
            +
                    specification.length.times do |i|
         
     | 
| 
      
 93 
     | 
    
         
            +
                      caret = specification[i..i] == '^' ? caret + 1 : 0
         
     | 
| 
      
 94 
     | 
    
         
            +
                      if caret[0] == 0 && specification[i..i] == ':'
         
     | 
| 
      
 95 
     | 
    
         
            +
                        specification[0...i].gsub(/\^./) {|escape| RFC6868[escape] || escape}.
         
     | 
| 
      
 96 
     | 
    
         
            +
                          scan(/((?:[^\\;]|\\.)+)(?:;(?!\z))?|;/).flatten.each do |pr|
         
     | 
| 
      
 97 
     | 
    
         
            +
                          pr ||= ''
         
     | 
| 
      
 98 
     | 
    
         
            +
                          pr.gsub!(/\\./) {|escape| RFC6350[escape] || escape}
         
     | 
| 
      
 99 
     | 
    
         
            +
                          key, value = pr.split(/=/, 2)
         
     | 
| 
      
 100 
     | 
    
         
            +
                          case key
         
     | 
| 
      
 101 
     | 
    
         
            +
                          when 'VALUE' ; options[:precision] = value
         
     | 
| 
      
 102 
     | 
    
         
            +
                          when 'TZID'  ; options[:clock] = 
         
     | 
| 
      
 103 
     | 
    
         
            +
                            case When::V::Timezone[value]
         
     | 
| 
      
 104 
     | 
    
         
            +
                            when Array ; When::V::Timezone[value][-1]
         
     | 
| 
      
 105 
     | 
    
         
            +
                            when nil   ; When::Parts::Timezone.new(value)
         
     | 
| 
      
 106 
     | 
    
         
            +
                            else       ; When::V::Timezone[value]
         
     | 
| 
      
 107 
     | 
    
         
            +
                            end
         
     | 
| 
      
 108 
     | 
    
         
            +
                          else         ; options[key]    = value
         
     | 
| 
      
 109 
     | 
    
         
            +
                          end
         
     | 
| 
      
 110 
     | 
    
         
            +
                        end
         
     | 
| 
      
 111 
     | 
    
         
            +
                        return specification[(i+1)..-1]
         
     | 
| 
      
 112 
     | 
    
         
            +
                      end
         
     | 
| 
      
 113 
     | 
    
         
            +
                    end
         
     | 
| 
      
 114 
     | 
    
         
            +
                    return specification
         
     | 
| 
      
 115 
     | 
    
         
            +
                  end
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 119 
     | 
    
         
            +
                module Synchronize
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                  # 排他実行
         
     | 
| 
      
 122 
     | 
    
         
            +
                  #
         
     | 
| 
      
 123 
     | 
    
         
            +
                  #   与えられたブロックを必要なら排他制御をして実行する
         
     | 
| 
      
 124 
     | 
    
         
            +
                  #
         
     | 
| 
      
 125 
     | 
    
         
            +
                  def synchronize
         
     | 
| 
      
 126 
     | 
    
         
            +
                    if @_lock_
         
     | 
| 
      
 127 
     | 
    
         
            +
                      @_lock_.synchronize do
         
     | 
| 
      
 128 
     | 
    
         
            +
                        yield
         
     | 
| 
      
 129 
     | 
    
         
            +
                      end
         
     | 
| 
      
 130 
     | 
    
         
            +
                    else
         
     | 
| 
      
 131 
     | 
    
         
            +
                      yield
         
     | 
| 
      
 132 
     | 
    
         
            +
                    end
         
     | 
| 
      
 133 
     | 
    
         
            +
                  end
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                #
         
     | 
| 
      
 137 
     | 
    
         
            +
                # Resource の has-a 親子関係を管理する
         
     | 
| 
      
 138 
     | 
    
         
            +
                #
         
     | 
| 
      
 139 
     | 
    
         
            +
                module Pool
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                  include Synchronize
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                  # 初期化
         
     | 
| 
      
 144 
     | 
    
         
            +
                  # @return [void]
         
     | 
| 
      
 145 
     | 
    
         
            +
                  #
         
     | 
| 
      
 146 
     | 
    
         
            +
                  # @note
         
     | 
| 
      
 147 
     | 
    
         
            +
                  #   本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
         
     | 
| 
      
 148 
     | 
    
         
            +
                  #   このため、本メソッド自体はスレッドセーフでない。
         
     | 
| 
      
 149 
     | 
    
         
            +
                  #
         
     | 
| 
      
 150 
     | 
    
         
            +
                  def _setup_
         
     | 
| 
      
 151 
     | 
    
         
            +
                    @_lock_ = Mutex.new if When.multi_thread
         
     | 
| 
      
 152 
     | 
    
         
            +
                    @_pool  = {}
         
     | 
| 
      
 153 
     | 
    
         
            +
                  end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                  # オブジェクト参照
         
     | 
| 
      
 156 
     | 
    
         
            +
                  #
         
     | 
| 
      
 157 
     | 
    
         
            +
                  # @param [String] label
         
     | 
| 
      
 158 
     | 
    
         
            +
                  #
         
     | 
| 
      
 159 
     | 
    
         
            +
                  # @return [When::Parts::Resource] 指定した label で登録した子 Resource を返す
         
     | 
| 
      
 160 
     | 
    
         
            +
                  #
         
     | 
| 
      
 161 
     | 
    
         
            +
                  def [](label)
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                    # nil label の場合
         
     | 
| 
      
 164 
     | 
    
         
            +
                    return _pool[label] unless label
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                    # 階層がある場合
         
     | 
| 
      
 167 
     | 
    
         
            +
                    terms = Resource._encode(label).split(/::/)
         
     | 
| 
      
 168 
     | 
    
         
            +
                    terms.shift if terms[0] == ''
         
     | 
| 
      
 169 
     | 
    
         
            +
                    return terms.inject(self) {|obj,term| obj = obj[Resource._decode(term)]} if terms.length >= 2
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                    # 階層がない場合
         
     | 
| 
      
 172 
     | 
    
         
            +
                    _pool[Resource._decode(Resource._extract_prefix(terms[0]))]
         
     | 
| 
      
 173 
     | 
    
         
            +
                  end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                  # オブジェクト登録
         
     | 
| 
      
 176 
     | 
    
         
            +
                  #
         
     | 
| 
      
 177 
     | 
    
         
            +
                  # 指定した label で子 Resource を登録する
         
     | 
| 
      
 178 
     | 
    
         
            +
                  #
         
     | 
| 
      
 179 
     | 
    
         
            +
                  # @param [String] label
         
     | 
| 
      
 180 
     | 
    
         
            +
                  # @param [When::Parts::Resource] obj
         
     | 
| 
      
 181 
     | 
    
         
            +
                  #
         
     | 
| 
      
 182 
     | 
    
         
            +
                  # @return [void]
         
     | 
| 
      
 183 
     | 
    
         
            +
                  #
         
     | 
| 
      
 184 
     | 
    
         
            +
                  def []=(label, obj)
         
     | 
| 
      
 185 
     | 
    
         
            +
                    # raise NameError, "Name duplication" if (@_pool[label])
         
     | 
| 
      
 186 
     | 
    
         
            +
                    _pool[label] = obj
         
     | 
| 
      
 187 
     | 
    
         
            +
                  end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 190 
     | 
    
         
            +
                  def pool_keys
         
     | 
| 
      
 191 
     | 
    
         
            +
                    _pool.keys
         
     | 
| 
      
 192 
     | 
    
         
            +
                  end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 195 
     | 
    
         
            +
                  def _pool
         
     | 
| 
      
 196 
     | 
    
         
            +
                    _setup_ unless @_pool
         
     | 
| 
      
 197 
     | 
    
         
            +
                    @_pool
         
     | 
| 
      
 198 
     | 
    
         
            +
                  end
         
     | 
| 
      
 199 
     | 
    
         
            +
                end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                  include Pool
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                  # Base URI for When_exe Resources
         
     | 
| 
      
 206 
     | 
    
         
            +
                  #
         
     | 
| 
      
 207 
     | 
    
         
            +
                  # @return [String]
         
     | 
| 
      
 208 
     | 
    
         
            +
                  #
         
     | 
| 
      
 209 
     | 
    
         
            +
                  def base_uri
         
     | 
| 
      
 210 
     | 
    
         
            +
                    @base_uri ||= When::SourceURI
         
     | 
| 
      
 211 
     | 
    
         
            +
                  end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                  # Root Directory for When_exe Resources
         
     | 
| 
      
 214 
     | 
    
         
            +
                  #
         
     | 
| 
      
 215 
     | 
    
         
            +
                  # @return [String]
         
     | 
| 
      
 216 
     | 
    
         
            +
                  #
         
     | 
| 
      
 217 
     | 
    
         
            +
                  def root_dir
         
     | 
| 
      
 218 
     | 
    
         
            +
                    @root_dir ||= When::RootDir
         
     | 
| 
      
 219 
     | 
    
         
            +
                  end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                  #
         
     | 
| 
      
 222 
     | 
    
         
            +
                  # 略称を iri に変換する
         
     | 
| 
      
 223 
     | 
    
         
            +
                  #
         
     | 
| 
      
 224 
     | 
    
         
            +
                  # @param [String or Symbol] abbreviation 略称
         
     | 
| 
      
 225 
     | 
    
         
            +
                  #
         
     | 
| 
      
 226 
     | 
    
         
            +
                  # @return [String] iri or nil
         
     | 
| 
      
 227 
     | 
    
         
            +
                  #
         
     | 
| 
      
 228 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 229 
     | 
    
         
            +
                  def _abbreviation_to_iri(abbreviation, abbreviation_types=ConstTypes)
         
     | 
| 
      
 230 
     | 
    
         
            +
                    abbreviation_types[:pattern] ||= /\A(?=[A-Z])(.*?)(#{abbreviation_types.keys.compact.join('|')})?(\?.+|::.+)?\z/
         
     | 
| 
      
 231 
     | 
    
         
            +
                    abbreviation.to_s =~ abbreviation_types[:pattern]
         
     | 
| 
      
 232 
     | 
    
         
            +
                    return nil unless $1
         
     | 
| 
      
 233 
     | 
    
         
            +
                    klass, name, iri = abbreviation_types[$2]
         
     | 
| 
      
 234 
     | 
    
         
            +
                    key,   name, iri = $2, name % $1, iri % [$1,$3]
         
     | 
| 
      
 235 
     | 
    
         
            +
                    if klass.kind_of?(String)
         
     | 
| 
      
 236 
     | 
    
         
            +
                      klass = klass.split('::').inject(When) {|k,n| k.const_get(n)}
         
     | 
| 
      
 237 
     | 
    
         
            +
                      abbreviation_types[key][0] = klass
         
     | 
| 
      
 238 
     | 
    
         
            +
                    end
         
     | 
| 
      
 239 
     | 
    
         
            +
                    klass.const_defined?(name) ? iri : nil
         
     | 
| 
      
 240 
     | 
    
         
            +
                  end
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 243 
     | 
    
         
            +
                  attr_reader :_prefix, :_prefix_values, :_prefix_index
         
     | 
| 
      
 244 
     | 
    
         
            +
                  private     :_prefix, :_prefix_values, :_prefix_index
         
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
      
 246 
     | 
    
         
            +
                  # 初期化
         
     | 
| 
      
 247 
     | 
    
         
            +
                  #
         
     | 
| 
      
 248 
     | 
    
         
            +
                  # @param [Hash] options 以下の通り
         
     | 
| 
      
 249 
     | 
    
         
            +
                  # @option options [String]  :base_uri Base URI for When_exe Resources (Default When::SourceURI)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  # @option options [Hash<String(namespace)=>String(URI)>] :additional_namespaces User defined namespaces (Default {})
         
     | 
| 
      
 251 
     | 
    
         
            +
                  # @option options [String]  :root_dir Root Directory for When_exe Resources Cash data (Default When::RootDir)
         
     | 
| 
      
 252 
     | 
    
         
            +
                  # @option options [Boolean] :leave_const If true, leave Constants of When module defined
         
     | 
| 
      
 253 
     | 
    
         
            +
                  #
         
     | 
| 
      
 254 
     | 
    
         
            +
                  # @return [void]
         
     | 
| 
      
 255 
     | 
    
         
            +
                  #
         
     | 
| 
      
 256 
     | 
    
         
            +
                  # @note
         
     | 
| 
      
 257 
     | 
    
         
            +
                  #   本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
         
     | 
| 
      
 258 
     | 
    
         
            +
                  #   このため、本メソッド自体はスレッドセーフでない。
         
     | 
| 
      
 259 
     | 
    
         
            +
                  #
         
     | 
| 
      
 260 
     | 
    
         
            +
                  def _setup_(options={})
         
     | 
| 
      
 261 
     | 
    
         
            +
                    super()
         
     | 
| 
      
 262 
     | 
    
         
            +
                    @_prefix = {
         
     | 
| 
      
 263 
     | 
    
         
            +
                      '_wp'  => 'http://en.wikipedia.org/wiki/',
         
     | 
| 
      
 264 
     | 
    
         
            +
                      '_w'   => base_uri + '/',
         
     | 
| 
      
 265 
     | 
    
         
            +
                      '_p'   => base_uri + 'Parts/',
         
     | 
| 
      
 266 
     | 
    
         
            +
                      '_b'   => base_uri + 'BasicTypes/',
         
     | 
| 
      
 267 
     | 
    
         
            +
                      '_m'   => base_uri + 'BasicTypes/M17n/',
         
     | 
| 
      
 268 
     | 
    
         
            +
                      '_co'  => base_uri + 'Coordinates/',
         
     | 
| 
      
 269 
     | 
    
         
            +
                      '_l'   => base_uri + 'Coordinates/Spatial?',
         
     | 
| 
      
 270 
     | 
    
         
            +
                      '_v'   => base_uri + 'V/',
         
     | 
| 
      
 271 
     | 
    
         
            +
                      '_rs'  => base_uri + 'RS/',
         
     | 
| 
      
 272 
     | 
    
         
            +
                      '_ex'  => base_uri + 'EX/',
         
     | 
| 
      
 273 
     | 
    
         
            +
                      '_tm'  => base_uri + 'TM/',
         
     | 
| 
      
 274 
     | 
    
         
            +
                      '_e'   => base_uri + 'TM/CalendarEra/',
         
     | 
| 
      
 275 
     | 
    
         
            +
                      '_t'   => base_uri + 'TimeStandard/',
         
     | 
| 
      
 276 
     | 
    
         
            +
                      '_ep'  => base_uri + 'Ephemeris/',
         
     | 
| 
      
 277 
     | 
    
         
            +
                      '_c'   => base_uri + 'CalendarTypes/',
         
     | 
| 
      
 278 
     | 
    
         
            +
                      '_n'   => base_uri + 'CalendarNote/',
         
     | 
| 
      
 279 
     | 
    
         
            +
                      '_sc'  => base_uri + 'Ephemeris/V50/'
         
     | 
| 
      
 280 
     | 
    
         
            +
                    }
         
     | 
| 
      
 281 
     | 
    
         
            +
                    @base_uri       = options[:base_uri] || When::SourceURI
         
     | 
| 
      
 282 
     | 
    
         
            +
                    @root_dir       = options[:root_dir] || When::RootDir
         
     | 
| 
      
 283 
     | 
    
         
            +
                    @_prefix        = options[:additional_namespaces].merge(@_prefix) if options[:additional_namespaces].kind_of?(Hash)
         
     | 
| 
      
 284 
     | 
    
         
            +
                    @_prefix_values = @_prefix.values.sort.reverse
         
     | 
| 
      
 285 
     | 
    
         
            +
                    @_prefix_index  = @_prefix.invert
         
     | 
| 
      
 286 
     | 
    
         
            +
                    unless options[:leave_const] || ConstList.empty?
         
     | 
| 
      
 287 
     | 
    
         
            +
                      ConstList.delete_if do |constant|
         
     | 
| 
      
 288 
     | 
    
         
            +
                        When.send(:remove_const, constant) if When.const_defined?(constant)
         
     | 
| 
      
 289 
     | 
    
         
            +
                        true
         
     | 
| 
      
 290 
     | 
    
         
            +
                      end
         
     | 
| 
      
 291 
     | 
    
         
            +
                      When._define_common_calendar_types
         
     | 
| 
      
 292 
     | 
    
         
            +
                    end
         
     | 
| 
      
 293 
     | 
    
         
            +
                  end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                  # 設定情報を取得する
         
     | 
| 
      
 296 
     | 
    
         
            +
                  #
         
     | 
| 
      
 297 
     | 
    
         
            +
                  # @return [Hash] 設定情報
         
     | 
| 
      
 298 
     | 
    
         
            +
                  #
         
     | 
| 
      
 299 
     | 
    
         
            +
                  def _setup_info
         
     | 
| 
      
 300 
     | 
    
         
            +
                    {:base_uri => base_uri, :root_dir => root_dir}
         
     | 
| 
      
 301 
     | 
    
         
            +
                  end
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
                  # オブジェクト生成&参照
         
     | 
| 
      
 304 
     | 
    
         
            +
                  #
         
     | 
| 
      
 305 
     | 
    
         
            +
                  # 指定した iri の When::Parts::Resource オブジェクトを取得する。
         
     | 
| 
      
 306 
     | 
    
         
            +
                  # 当該オブジェクトが未登録であれば生成する。
         
     | 
| 
      
 307 
     | 
    
         
            +
                  #
         
     | 
| 
      
 308 
     | 
    
         
            +
                  # @param [String] iri International Resource Identifier
         
     | 
| 
      
 309 
     | 
    
         
            +
                  # @param [String] namespace (デフォルトの名前空間, 指定がないときは名前空間を省略しない)
         
     | 
| 
      
 310 
     | 
    
         
            +
                  # @param [Block] block オブジェクトが見つからない場合の代替処理
         
     | 
| 
      
 311 
     | 
    
         
            +
                  #
         
     | 
| 
      
 312 
     | 
    
         
            +
                  # @return [When::Parts::Resource]
         
     | 
| 
      
 313 
     | 
    
         
            +
                  #
         
     | 
| 
      
 314 
     | 
    
         
            +
                  def _instance(iri, namespace=nil, &block)
         
     | 
| 
      
 315 
     | 
    
         
            +
                    _setup_ unless @_pool
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
                    case iri
         
     | 
| 
      
 318 
     | 
    
         
            +
                    when Array    ; return iri.map {|e| _instance(e, namespace)}                  # 配列は個別に処理
         
     | 
| 
      
 319 
     | 
    
         
            +
                    when Resource ; return iri                                                    # 登録済みはそのまま
         
     | 
| 
      
 320 
     | 
    
         
            +
                    when String   ;                                                               # 解析処理へ
         
     | 
| 
      
 321 
     | 
    
         
            +
                    else          ; raise ArgumentError, "can't convert #{iri.class} to String"   # 例外
         
     | 
| 
      
 322 
     | 
    
         
            +
                    end
         
     | 
| 
      
 323 
     | 
    
         
            +
             
     | 
| 
      
 324 
     | 
    
         
            +
                    # 内部文字列化
         
     | 
| 
      
 325 
     | 
    
         
            +
                    iri = When::EncodingConversion.to_internal_encoding(iri)
         
     | 
| 
      
 326 
     | 
    
         
            +
             
     | 
| 
      
 327 
     | 
    
         
            +
                    # 階層がある場合は、階層をたどる
         
     | 
| 
      
 328 
     | 
    
         
            +
                    iri = Resource._decode(iri)
         
     | 
| 
      
 329 
     | 
    
         
            +
                    iri = $1 while iri =~ /\A\((.*)\)\z/
         
     | 
| 
      
 330 
     | 
    
         
            +
                    iri = namespace + iri if namespace && iri !~ IRIHeader
         
     | 
| 
      
 331 
     | 
    
         
            +
                    root, *leaves= Resource._encode(iri).split(/::/)
         
     | 
| 
      
 332 
     | 
    
         
            +
                    if leaves.size > 0
         
     | 
| 
      
 333 
     | 
    
         
            +
                      return leaves.inject(_instance(Resource._decode(root))) {|obj,leaf| obj[Resource._decode(leaf)]}
         
     | 
| 
      
 334 
     | 
    
         
            +
                    end
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
                    # 登録ずみなら、参照
         
     | 
| 
      
 337 
     | 
    
         
            +
                    iri = _extract_prefix(iri)
         
     | 
| 
      
 338 
     | 
    
         
            +
                    path, query = iri.split(/\?/, 2)
         
     | 
| 
      
 339 
     | 
    
         
            +
                    if When.multi_thread
         
     | 
| 
      
 340 
     | 
    
         
            +
                      my_mutex = nil
         
     | 
| 
      
 341 
     | 
    
         
            +
                      @_lock_.synchronize do
         
     | 
| 
      
 342 
     | 
    
         
            +
                        @_pool ||= {}
         
     | 
| 
      
 343 
     | 
    
         
            +
                        unless @_pool[iri]
         
     | 
| 
      
 344 
     | 
    
         
            +
                          my_mutex    = Mutex.new
         
     | 
| 
      
 345 
     | 
    
         
            +
                          @_pool[iri] = my_mutex
         
     | 
| 
      
 346 
     | 
    
         
            +
                        end
         
     | 
| 
      
 347 
     | 
    
         
            +
                      end
         
     | 
| 
      
 348 
     | 
    
         
            +
                      case @_pool[iri]
         
     | 
| 
      
 349 
     | 
    
         
            +
                      when my_mutex; my_mutex.synchronize    {@_pool[iri] = _create_object(iri, path, query, &block) }
         
     | 
| 
      
 350 
     | 
    
         
            +
                      when Mutex   ; @_pool[iri].synchronize {@_pool[iri]}
         
     | 
| 
      
 351 
     | 
    
         
            +
                      else         ; @_pool[iri]
         
     | 
| 
      
 352 
     | 
    
         
            +
                      end
         
     | 
| 
      
 353 
     | 
    
         
            +
                    else
         
     | 
| 
      
 354 
     | 
    
         
            +
                      @_pool      ||= {}
         
     | 
| 
      
 355 
     | 
    
         
            +
                      @_pool[iri] ||= _create_object(iri, path, query, &block)
         
     | 
| 
      
 356 
     | 
    
         
            +
                    end
         
     | 
| 
      
 357 
     | 
    
         
            +
                  end
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 360 
     | 
    
         
            +
                  def _path_with_prefix(obj, simple=true)
         
     | 
| 
      
 361 
     | 
    
         
            +
                    _setup_ unless @_pool
         
     | 
| 
      
 362 
     | 
    
         
            +
                    path = obj.kind_of?(Class) ? obj.to_s.sub(/\AWhen::/, base_uri).gsub(/::/, '/') :
         
     | 
| 
      
 363 
     | 
    
         
            +
                                                 obj.iri
         
     | 
| 
      
 364 
     | 
    
         
            +
                    simple ? _simplify_path(path) : path
         
     | 
| 
      
 365 
     | 
    
         
            +
                  end
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
      
 367 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 368 
     | 
    
         
            +
                  def _simplify_path(path)
         
     | 
| 
      
 369 
     | 
    
         
            +
                    _prefix_values.each do |value|
         
     | 
| 
      
 370 
     | 
    
         
            +
                      index = path.index(value)
         
     | 
| 
      
 371 
     | 
    
         
            +
                      return _prefix_index[value] + ':' + path[value.length..-1] if index
         
     | 
| 
      
 372 
     | 
    
         
            +
                    end
         
     | 
| 
      
 373 
     | 
    
         
            +
                    return path
         
     | 
| 
      
 374 
     | 
    
         
            +
                  end
         
     | 
| 
      
 375 
     | 
    
         
            +
             
     | 
| 
      
 376 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 377 
     | 
    
         
            +
                  def _parse(line, type=nil)
         
     | 
| 
      
 378 
     | 
    
         
            +
                    return line unless line.kind_of?(String)
         
     | 
| 
      
 379 
     | 
    
         
            +
                    line.sub!(/\s#.*\z/, '')
         
     | 
| 
      
 380 
     | 
    
         
            +
                    return When::Locale._split($1) if type && /\A#{type}:(.+)\z/i =~ line
         
     | 
| 
      
 381 
     | 
    
         
            +
                    tokens = line.scan(/((?:[^\\:]|\\.)+)(?::(?!\z))?|:/).flatten
         
     | 
| 
      
 382 
     | 
    
         
            +
                    return When::Locale._split(line) unless tokens.size > 1 && /\A(\*)?([A-Z][-A-Z_]{0,255})(?:;(.+))?\z/i =~ tokens[0]
         
     | 
| 
      
 383 
     | 
    
         
            +
                    marked, key, property = $~[1..3]
         
     | 
| 
      
 384 
     | 
    
         
            +
                    values = tokens[1..-1]
         
     | 
| 
      
 385 
     | 
    
         
            +
                    value  = values.join(':') unless values == [nil]
         
     | 
| 
      
 386 
     | 
    
         
            +
                    content = ContentLine.new(key, value, marked)
         
     | 
| 
      
 387 
     | 
    
         
            +
                    value ||= ''
         
     | 
| 
      
 388 
     | 
    
         
            +
                    if property
         
     | 
| 
      
 389 
     | 
    
         
            +
                      content.attribute['.'] = property + ':' + value
         
     | 
| 
      
 390 
     | 
    
         
            +
                      property.scan(/((?:[^\\;]|\\.)+)(?:;(?!\z))?|;/).flatten.each do |pr|
         
     | 
| 
      
 391 
     | 
    
         
            +
                        pr ||= ''
         
     | 
| 
      
 392 
     | 
    
         
            +
                        pr.gsub!(/\\./) {|escape| ContentLine::RFC6350[escape] || escape}
         
     | 
| 
      
 393 
     | 
    
         
            +
                        prop = ContentLine.new(*pr.split(/=/, 2))
         
     | 
| 
      
 394 
     | 
    
         
            +
                        content.attribute[prop.predicate] = prop
         
     | 
| 
      
 395 
     | 
    
         
            +
                      end
         
     | 
| 
      
 396 
     | 
    
         
            +
                    else
         
     | 
| 
      
 397 
     | 
    
         
            +
                      content.attribute['.'] = value
         
     | 
| 
      
 398 
     | 
    
         
            +
                    end
         
     | 
| 
      
 399 
     | 
    
         
            +
                    return content
         
     | 
| 
      
 400 
     | 
    
         
            +
                  end
         
     | 
| 
      
 401 
     | 
    
         
            +
             
     | 
| 
      
 402 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 403 
     | 
    
         
            +
                  def _extract_prefix(path, capitalize=false)
         
     | 
| 
      
 404 
     | 
    
         
            +
                    if (path =~ /\A(.+?):+(.+)\z/)
         
     | 
| 
      
 405 
     | 
    
         
            +
                      prefix, klass = $~[1..2]
         
     | 
| 
      
 406 
     | 
    
         
            +
                      if capitalize
         
     | 
| 
      
 407 
     | 
    
         
            +
                        prefix = '_' + prefix.downcase
         
     | 
| 
      
 408 
     | 
    
         
            +
                        klass  = klass.capitalize if klass == klass.upcase
         
     | 
| 
      
 409 
     | 
    
         
            +
                      end
         
     | 
| 
      
 410 
     | 
    
         
            +
                      path = _prefix[prefix] + klass if _prefix[prefix]
         
     | 
| 
      
 411 
     | 
    
         
            +
                    elsif capitalize && path =~ /\A(v[^\/]+|daylight$|standard$)/i
         
     | 
| 
      
 412 
     | 
    
         
            +
                      klass = path.sub(/\Av/i, '').capitalize
         
     | 
| 
      
 413 
     | 
    
         
            +
                      path  = _prefix['_v'] + klass if When::V.const_defined?(klass) &&
         
     | 
| 
      
 414 
     | 
    
         
            +
                                                       When::V.const_get(klass).kind_of?(Class)
         
     | 
| 
      
 415 
     | 
    
         
            +
                    end
         
     | 
| 
      
 416 
     | 
    
         
            +
                    return path
         
     | 
| 
      
 417 
     | 
    
         
            +
                  end
         
     | 
| 
      
 418 
     | 
    
         
            +
             
     | 
| 
      
 419 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 420 
     | 
    
         
            +
                  def _replace_tags(source, tags)
         
     | 
| 
      
 421 
     | 
    
         
            +
                    case source
         
     | 
| 
      
 422 
     | 
    
         
            +
                    when When::BasicTypes::M17n
         
     | 
| 
      
 423 
     | 
    
         
            +
                      source
         
     | 
| 
      
 424 
     | 
    
         
            +
                    when String
         
     | 
| 
      
 425 
     | 
    
         
            +
                      target = source.dup
         
     | 
| 
      
 426 
     | 
    
         
            +
                      tags.each_pair do |key, value|
         
     | 
| 
      
 427 
     | 
    
         
            +
                        target.gsub!(/#\{([?&][^=#}]+?=)?#{key}(:.*?)?\}/, '\1' + value) if value.kind_of?(String)
         
     | 
| 
      
 428 
     | 
    
         
            +
                      end
         
     | 
| 
      
 429 
     | 
    
         
            +
                      target.gsub(/#\{.+?(:(.*?))?\}/, '\2')
         
     | 
| 
      
 430 
     | 
    
         
            +
                    when Array
         
     | 
| 
      
 431 
     | 
    
         
            +
                      source.map {|target| _replace_tags(target, tags)}
         
     | 
| 
      
 432 
     | 
    
         
            +
                    when Hash
         
     | 
| 
      
 433 
     | 
    
         
            +
                      target = {}
         
     | 
| 
      
 434 
     | 
    
         
            +
                      source.each_pair do |key, value|
         
     | 
| 
      
 435 
     | 
    
         
            +
                        target[key] = _replace_tags(tags[key] || value, tags)
         
     | 
| 
      
 436 
     | 
    
         
            +
                      end
         
     | 
| 
      
 437 
     | 
    
         
            +
                      target
         
     | 
| 
      
 438 
     | 
    
         
            +
                    else
         
     | 
| 
      
 439 
     | 
    
         
            +
                      source
         
     | 
| 
      
 440 
     | 
    
         
            +
                    end
         
     | 
| 
      
 441 
     | 
    
         
            +
                  end
         
     | 
| 
      
 442 
     | 
    
         
            +
             
     | 
| 
      
 443 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 444 
     | 
    
         
            +
                  def _encode(iri)
         
     | 
| 
      
 445 
     | 
    
         
            +
                    return iri unless iri =~ /\(/
         
     | 
| 
      
 446 
     | 
    
         
            +
             
     | 
| 
      
 447 
     | 
    
         
            +
                    iri = iri.dup
         
     | 
| 
      
 448 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 449 
     | 
    
         
            +
                      unless iri.gsub!(/\([^()]*\)/) {|token|
         
     | 
| 
      
 450 
     | 
    
         
            +
                        token.gsub(/[():?&%]/) {|char|'%' + char.ord.to_s(16)}
         
     | 
| 
      
 451 
     | 
    
         
            +
                      }
         
     | 
| 
      
 452 
     | 
    
         
            +
                        raise ArgumentError, 'Brackets do not correspond: ' + iri 
         
     | 
| 
      
 453 
     | 
    
         
            +
                      end
         
     | 
| 
      
 454 
     | 
    
         
            +
                    end while iri =~ /\(/
         
     | 
| 
      
 455 
     | 
    
         
            +
                    iri
         
     | 
| 
      
 456 
     | 
    
         
            +
                  end
         
     | 
| 
      
 457 
     | 
    
         
            +
             
     | 
| 
      
 458 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 459 
     | 
    
         
            +
                  def _decode(iri)
         
     | 
| 
      
 460 
     | 
    
         
            +
                    iri = iri.gsub(When::Parts::Resource::IRIDecode) {|c| When::Parts::Resource::IRIDecodeTable[c]}
         
     | 
| 
      
 461 
     | 
    
         
            +
                    return iri unless iri =~ /%28/
         
     | 
| 
      
 462 
     | 
    
         
            +
             
     | 
| 
      
 463 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 464 
     | 
    
         
            +
                      unless iri.gsub!(/%28.*?%29/) {|token|
         
     | 
| 
      
 465 
     | 
    
         
            +
                        token.gsub(/%([\dA-F]{2})/i) {$1.to_i(16).chr}
         
     | 
| 
      
 466 
     | 
    
         
            +
                      }
         
     | 
| 
      
 467 
     | 
    
         
            +
                        raise ArgumentError, 'Brackets do not correspond: ' + iri 
         
     | 
| 
      
 468 
     | 
    
         
            +
                      end
         
     | 
| 
      
 469 
     | 
    
         
            +
                    end while iri =~ /%28/
         
     | 
| 
      
 470 
     | 
    
         
            +
                    iri = $1 if iri =~ /\A\((.*)\)\z/
         
     | 
| 
      
 471 
     | 
    
         
            +
                    iri
         
     | 
| 
      
 472 
     | 
    
         
            +
                  end
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
                  # @private
         
     | 
| 
      
 475 
     | 
    
         
            +
                  def _instantiate(resource)
         
     | 
| 
      
 476 
     | 
    
         
            +
                    return resource unless resource.kind_of?(Array)
         
     | 
| 
      
 477 
     | 
    
         
            +
                    return resource[0].new(*resource[1..-1]) if resource[0].kind_of?(Class)
         
     | 
| 
      
 478 
     | 
    
         
            +
                    return resource.map {|rsc| _instantiate(rsc)}
         
     | 
| 
      
 479 
     | 
    
         
            +
                  end
         
     | 
| 
      
 480 
     | 
    
         
            +
             
     | 
| 
      
 481 
     | 
    
         
            +
                  private
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
      
 483 
     | 
    
         
            +
                  # オブジェクト生成
         
     | 
| 
      
 484 
     | 
    
         
            +
                  def _create_object(iri, path, query, &block)
         
     | 
| 
      
 485 
     | 
    
         
            +
                    # query analyzation
         
     | 
| 
      
 486 
     | 
    
         
            +
                    options = {}
         
     | 
| 
      
 487 
     | 
    
         
            +
                    replace = {}
         
     | 
| 
      
 488 
     | 
    
         
            +
                    if query
         
     | 
| 
      
 489 
     | 
    
         
            +
                      options = Hash[*Resource._encode(query).split(/&/).map{|pair|
         
     | 
| 
      
 490 
     | 
    
         
            +
                        key, value = pair.split(/=/, 2)
         
     | 
| 
      
 491 
     | 
    
         
            +
                        [key, Resource._decode(value)]
         
     | 
| 
      
 492 
     | 
    
         
            +
                      }.flatten]
         
     | 
| 
      
 493 
     | 
    
         
            +
                      keys    = options.keys
         
     | 
| 
      
 494 
     | 
    
         
            +
                      keys.each do |key|
         
     | 
| 
      
 495 
     | 
    
         
            +
                        replace[$1] = options.delete(key) if key =~ /\A([A-Z].*)/
         
     | 
| 
      
 496 
     | 
    
         
            +
                      end
         
     | 
| 
      
 497 
     | 
    
         
            +
                    end
         
     | 
| 
      
 498 
     | 
    
         
            +
                    options['..'] = iri
         
     | 
| 
      
 499 
     | 
    
         
            +
             
     | 
| 
      
 500 
     | 
    
         
            +
                    # internal Resource
         
     | 
| 
      
 501 
     | 
    
         
            +
                    if path.index(Resource.base_uri) == 0
         
     | 
| 
      
 502 
     | 
    
         
            +
                      list = _class(path)
         
     | 
| 
      
 503 
     | 
    
         
            +
                      if list
         
     | 
| 
      
 504 
     | 
    
         
            +
                        return _internal(list, replace, options)
         
     | 
| 
      
 505 
     | 
    
         
            +
                      else
         
     | 
| 
      
 506 
     | 
    
         
            +
                        object = yield(iri) if block_given?
         
     | 
| 
      
 507 
     | 
    
         
            +
                        return object if object
         
     | 
| 
      
 508 
     | 
    
         
            +
                        raise IOError, 'IRI not found - ' + path
         
     | 
| 
      
 509 
     | 
    
         
            +
                      end
         
     | 
| 
      
 510 
     | 
    
         
            +
                    end
         
     | 
| 
      
 511 
     | 
    
         
            +
             
     | 
| 
      
 512 
     | 
    
         
            +
                    # external Resource
         
     | 
| 
      
 513 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 514 
     | 
    
         
            +
                      object = When::Locale.send(:wikipedia_object, path, {:query=>query})
         
     | 
| 
      
 515 
     | 
    
         
            +
                      return object if object
         
     | 
| 
      
 516 
     | 
    
         
            +
                      OpenURI
         
     | 
| 
      
 517 
     | 
    
         
            +
                      args  = [path, "1".respond_to?(:force_encoding) ? 'r:utf-8' : 'r']
         
     | 
| 
      
 518 
     | 
    
         
            +
                      args << {:ssl_verify_mode=>OpenSSL::SSL::VERIFY_NONE} if path =~ /\Ahttps:/
         
     | 
| 
      
 519 
     | 
    
         
            +
                      open(*args) do |file|
         
     | 
| 
      
 520 
     | 
    
         
            +
                        resource = file.read
         
     | 
| 
      
 521 
     | 
    
         
            +
                        case resource[0..5].upcase
         
     | 
| 
      
 522 
     | 
    
         
            +
                        when 'BEGIN:'
         
     | 
| 
      
 523 
     | 
    
         
            +
                          options['.'] = _ics(_replace_tags(resource, replace).split(/[\n\r]+/))
         
     | 
| 
      
 524 
     | 
    
         
            +
                          options['.'][0].new(options)
         
     | 
| 
      
 525 
     | 
    
         
            +
                        when '<?XML '
         
     | 
| 
      
 526 
     | 
    
         
            +
                          options['.'] = _xml(REXML::Document.new(_replace_tags(resource, replace)).root)
         
     | 
| 
      
 527 
     | 
    
         
            +
                          options['.'][0].new(options)
         
     | 
| 
      
 528 
     | 
    
         
            +
                        else
         
     | 
| 
      
 529 
     | 
    
         
            +
                          raise NoMethodError, 'JSON not supported' unless Object.const_defined?(:JSON)
         
     | 
| 
      
 530 
     | 
    
         
            +
                          _internal(_json([JSON.parse(resource)]), replace, options)
         
     | 
| 
      
 531 
     | 
    
         
            +
                        end
         
     | 
| 
      
 532 
     | 
    
         
            +
                      end
         
     | 
| 
      
 533 
     | 
    
         
            +
                    rescue OpenURI::HTTPError => error
         
     | 
| 
      
 534 
     | 
    
         
            +
                      message = error.message + " - #{path}"
         
     | 
| 
      
 535 
     | 
    
         
            +
                      error   = error.respond_to?(:uri) ?
         
     | 
| 
      
 536 
     | 
    
         
            +
                                  error.class.new(message, error.io, error.uri) :
         
     | 
| 
      
 537 
     | 
    
         
            +
                                  error.class.new(message, error.io)
         
     | 
| 
      
 538 
     | 
    
         
            +
                      raise error
         
     | 
| 
      
 539 
     | 
    
         
            +
                    end
         
     | 
| 
      
 540 
     | 
    
         
            +
                  end
         
     | 
| 
      
 541 
     | 
    
         
            +
             
     | 
| 
      
 542 
     | 
    
         
            +
                  # 指定のモジュール/クラスで直接定数が定義されているか
         
     | 
| 
      
 543 
     | 
    
         
            +
                  if method(:const_defined?).arity == 1
         
     | 
| 
      
 544 
     | 
    
         
            +
                    def _directry_defined?(klass, const)
         
     | 
| 
      
 545 
     | 
    
         
            +
                      klass.const_defined?(const)
         
     | 
| 
      
 546 
     | 
    
         
            +
                    end
         
     | 
| 
      
 547 
     | 
    
         
            +
                  else
         
     | 
| 
      
 548 
     | 
    
         
            +
                    def _directry_defined?(klass, const)
         
     | 
| 
      
 549 
     | 
    
         
            +
                      klass.const_defined?(const, false)
         
     | 
| 
      
 550 
     | 
    
         
            +
                    end
         
     | 
| 
      
 551 
     | 
    
         
            +
                  end
         
     | 
| 
      
 552 
     | 
    
         
            +
             
     | 
| 
      
 553 
     | 
    
         
            +
                  # 内部形式定義の取得
         
     | 
| 
      
 554 
     | 
    
         
            +
                  def _class(path)
         
     | 
| 
      
 555 
     | 
    
         
            +
                    list = [When]
         
     | 
| 
      
 556 
     | 
    
         
            +
                    path[Resource.base_uri.length..-1].split(/\//).each do |mod|
         
     | 
| 
      
 557 
     | 
    
         
            +
                      if list[0].kind_of?(Module) && _directry_defined?(list[0], mod)
         
     | 
| 
      
 558 
     | 
    
         
            +
                        list.unshift(list[0].const_get(mod))
         
     | 
| 
      
 559 
     | 
    
         
            +
                      else
         
     | 
| 
      
 560 
     | 
    
         
            +
                        return nil unless list[0] == When::V
         
     | 
| 
      
 561 
     | 
    
         
            +
                        list.unshift(When::V::Root)
         
     | 
| 
      
 562 
     | 
    
         
            +
                        return list
         
     | 
| 
      
 563 
     | 
    
         
            +
                      end
         
     | 
| 
      
 564 
     | 
    
         
            +
                    end
         
     | 
| 
      
 565 
     | 
    
         
            +
                    return list
         
     | 
| 
      
 566 
     | 
    
         
            +
                  end
         
     | 
| 
      
 567 
     | 
    
         
            +
             
     | 
| 
      
 568 
     | 
    
         
            +
                  # 内部形式定義のオブジェクト化
         
     | 
| 
      
 569 
     | 
    
         
            +
                  def _internal(list, replace, options)
         
     | 
| 
      
 570 
     | 
    
         
            +
                    case list[0]
         
     | 
| 
      
 571 
     | 
    
         
            +
                    when Class
         
     | 
| 
      
 572 
     | 
    
         
            +
                      list[0].new(options)
         
     | 
| 
      
 573 
     | 
    
         
            +
                    when Array
         
     | 
| 
      
 574 
     | 
    
         
            +
                      top = list[0][0]
         
     | 
| 
      
 575 
     | 
    
         
            +
                      if top.kind_of?(Hash)
         
     | 
| 
      
 576 
     | 
    
         
            +
                        top.each_pair do |key, value|
         
     | 
| 
      
 577 
     | 
    
         
            +
                          replace.update(value[replace[key]]) if value.kind_of?(Hash) && value[replace[key]]
         
     | 
| 
      
 578 
     | 
    
         
            +
                        end
         
     | 
| 
      
 579 
     | 
    
         
            +
                        list[0] = list[0][1..-1]
         
     | 
| 
      
 580 
     | 
    
         
            +
                        list[0] = _replace_tags(list[0], top.merge(replace))
         
     | 
| 
      
 581 
     | 
    
         
            +
                      end
         
     | 
| 
      
 582 
     | 
    
         
            +
                      if list[0][0].kind_of?(Class)
         
     | 
| 
      
 583 
     | 
    
         
            +
                        # 配列の先頭がクラスである場合
         
     | 
| 
      
 584 
     | 
    
         
            +
                        klass, *list = list[0]
         
     | 
| 
      
 585 
     | 
    
         
            +
                        unless list[-1].kind_of?(Hash)
         
     | 
| 
      
 586 
     | 
    
         
            +
                          if list.length == 1
         
     | 
| 
      
 587 
     | 
    
         
            +
                            list[0] = {'.'=>Array(list[0])}
         
     | 
| 
      
 588 
     | 
    
         
            +
                          else
         
     | 
| 
      
 589 
     | 
    
         
            +
                            list << {}
         
     | 
| 
      
 590 
     | 
    
         
            +
                          end
         
     | 
| 
      
 591 
     | 
    
         
            +
                        end
         
     | 
| 
      
 592 
     | 
    
         
            +
                      else
         
     | 
| 
      
 593 
     | 
    
         
            +
                        # 配列の先頭がクラスではない場合
         
     | 
| 
      
 594 
     | 
    
         
            +
                        klass, *list = [list[1], *list[0]]
         
     | 
| 
      
 595 
     | 
    
         
            +
                        list << {} unless list[-1].kind_of?(Hash)
         
     | 
| 
      
 596 
     | 
    
         
            +
                      end
         
     | 
| 
      
 597 
     | 
    
         
            +
                      list[-1] = list[-1].merge(options)
         
     | 
| 
      
 598 
     | 
    
         
            +
                      klass.new(*list)
         
     | 
| 
      
 599 
     | 
    
         
            +
                    else
         
     | 
| 
      
 600 
     | 
    
         
            +
                      list[0]
         
     | 
| 
      
 601 
     | 
    
         
            +
                    end
         
     | 
| 
      
 602 
     | 
    
         
            +
                  end
         
     | 
| 
      
 603 
     | 
    
         
            +
             
     | 
| 
      
 604 
     | 
    
         
            +
                  # .xml フォーマットの読み込み
         
     | 
| 
      
 605 
     | 
    
         
            +
                  def _xml(xml, namespace={})
         
     | 
| 
      
 606 
     | 
    
         
            +
                    obj = [_class(_extract_prefix(xml.attributes['type'].to_s))[0]]
         
     | 
| 
      
 607 
     | 
    
         
            +
                    xml.attributes.each_pair do |key,value|
         
     | 
| 
      
 608 
     | 
    
         
            +
                      expanded_name = value.expanded_name
         
     | 
| 
      
 609 
     | 
    
         
            +
                      next unless (expanded_name =~ /\Axmlns/)
         
     | 
| 
      
 610 
     | 
    
         
            +
                      key = '' if expanded_name == 'xmlns'
         
     | 
| 
      
 611 
     | 
    
         
            +
                      namespace[key] = value.to_s
         
     | 
| 
      
 612 
     | 
    
         
            +
                    end
         
     | 
| 
      
 613 
     | 
    
         
            +
                    obj << ContentLine.new('xmlns:namespace', namespace) if (namespace.size>0)
         
     | 
| 
      
 614 
     | 
    
         
            +
                    xml.each do |e|
         
     | 
| 
      
 615 
     | 
    
         
            +
                      next unless defined? e.name
         
     | 
| 
      
 616 
     | 
    
         
            +
                      if (e.attributes['type'])
         
     | 
| 
      
 617 
     | 
    
         
            +
                        obj << _xml(e, namespace)
         
     | 
| 
      
 618 
     | 
    
         
            +
                      else
         
     | 
| 
      
 619 
     | 
    
         
            +
                        content = ContentLine.new(e.expanded_name, e.attributes['ref']||e.text)
         
     | 
| 
      
 620 
     | 
    
         
            +
                        e.attributes.each_pair do |key,value|
         
     | 
| 
      
 621 
     | 
    
         
            +
                          attr = ContentLine.new(value.name, value)
         
     | 
| 
      
 622 
     | 
    
         
            +
                          attr.namespace = value.prefix
         
     | 
| 
      
 623 
     | 
    
         
            +
                          content.attribute[key] = attr
         
     | 
| 
      
 624 
     | 
    
         
            +
                        end
         
     | 
| 
      
 625 
     | 
    
         
            +
                        obj << content
         
     | 
| 
      
 626 
     | 
    
         
            +
                      end
         
     | 
| 
      
 627 
     | 
    
         
            +
                    end
         
     | 
| 
      
 628 
     | 
    
         
            +
                    return obj
         
     | 
| 
      
 629 
     | 
    
         
            +
                  end
         
     | 
| 
      
 630 
     | 
    
         
            +
             
     | 
| 
      
 631 
     | 
    
         
            +
                  # .ics フォーマットの読み込み
         
     | 
| 
      
 632 
     | 
    
         
            +
                  def _ics(ics, type=nil)
         
     | 
| 
      
 633 
     | 
    
         
            +
                    obj = [type] if type
         
     | 
| 
      
 634 
     | 
    
         
            +
                    indent = nil
         
     | 
| 
      
 635 
     | 
    
         
            +
                    while (line = ics.shift) do
         
     | 
| 
      
 636 
     | 
    
         
            +
                      line.chomp!
         
     | 
| 
      
 637 
     | 
    
         
            +
                      case line
         
     | 
| 
      
 638 
     | 
    
         
            +
                      when /\A\s*BEGIN:(.*)\z/
         
     | 
| 
      
 639 
     | 
    
         
            +
                        if type
         
     | 
| 
      
 640 
     | 
    
         
            +
                          subtype = $1
         
     | 
| 
      
 641 
     | 
    
         
            +
                          obj[-1] = _parse(obj[-1], type) if obj.length > 1
         
     | 
| 
      
 642 
     | 
    
         
            +
                          obj << _ics(ics, subtype)
         
     | 
| 
      
 643 
     | 
    
         
            +
                        else
         
     | 
| 
      
 644 
     | 
    
         
            +
                          type = $1
         
     | 
| 
      
 645 
     | 
    
         
            +
                          obj  = [type]
         
     | 
| 
      
 646 
     | 
    
         
            +
                        end
         
     | 
| 
      
 647 
     | 
    
         
            +
                      when /\A\s*END:(.*)\z/
         
     | 
| 
      
 648 
     | 
    
         
            +
                        raise TypeError, "Irregal Type : #{$1}" unless type == $1
         
     | 
| 
      
 649 
     | 
    
         
            +
                        obj[0]  = _class(_extract_prefix(type, true))[0]
         
     | 
| 
      
 650 
     | 
    
         
            +
                        obj[-1] = _parse(obj[-1], type)
         
     | 
| 
      
 651 
     | 
    
         
            +
                        return obj
         
     | 
| 
      
 652 
     | 
    
         
            +
                      when /\A\s*#/
         
     | 
| 
      
 653 
     | 
    
         
            +
                      when /\A(\s*)(.*)\z/
         
     | 
| 
      
 654 
     | 
    
         
            +
                        indent  = $1 unless indent
         
     | 
| 
      
 655 
     | 
    
         
            +
                        if indent.length < $1.length
         
     | 
| 
      
 656 
     | 
    
         
            +
                          obj[-1] += line[(indent.length+1)..-1] # See RFC5545 3.1 Content Lines
         
     | 
| 
      
 657 
     | 
    
         
            +
                        else
         
     | 
| 
      
 658 
     | 
    
         
            +
                          obj << $2
         
     | 
| 
      
 659 
     | 
    
         
            +
                          obj[-2]  = _parse(obj[-2], type)
         
     | 
| 
      
 660 
     | 
    
         
            +
                        end
         
     | 
| 
      
 661 
     | 
    
         
            +
                      end
         
     | 
| 
      
 662 
     | 
    
         
            +
                    end
         
     | 
| 
      
 663 
     | 
    
         
            +
                    raise ArgumentError, "BEGIN-END mismatch"
         
     | 
| 
      
 664 
     | 
    
         
            +
                  end
         
     | 
| 
      
 665 
     | 
    
         
            +
             
     | 
| 
      
 666 
     | 
    
         
            +
                  # .json フォーマットの読み込み
         
     | 
| 
      
 667 
     | 
    
         
            +
                  def _json(json)
         
     | 
| 
      
 668 
     | 
    
         
            +
                    case json
         
     | 
| 
      
 669 
     | 
    
         
            +
                    when Array
         
     | 
| 
      
 670 
     | 
    
         
            +
                      json.map {|value| _json(value)}
         
     | 
| 
      
 671 
     | 
    
         
            +
                    when Hash
         
     | 
| 
      
 672 
     | 
    
         
            +
                      hash = {}
         
     | 
| 
      
 673 
     | 
    
         
            +
                      json.each_pair {|key, value| hash[key] = _json(value)}
         
     | 
| 
      
 674 
     | 
    
         
            +
                      hash
         
     | 
| 
      
 675 
     | 
    
         
            +
                    when String
         
     | 
| 
      
 676 
     | 
    
         
            +
                      return json unless json =~ /\AWhen::/
         
     | 
| 
      
 677 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 678 
     | 
    
         
            +
                        return json.split('::').inject(Object) {|ns, sym| ns.const_get(sym)}
         
     | 
| 
      
 679 
     | 
    
         
            +
                      rescue
         
     | 
| 
      
 680 
     | 
    
         
            +
                        json
         
     | 
| 
      
 681 
     | 
    
         
            +
                      end
         
     | 
| 
      
 682 
     | 
    
         
            +
                    else
         
     | 
| 
      
 683 
     | 
    
         
            +
                      json
         
     | 
| 
      
 684 
     | 
    
         
            +
                    end
         
     | 
| 
      
 685 
     | 
    
         
            +
                  end
         
     | 
| 
      
 686 
     | 
    
         
            +
                end
         
     | 
| 
      
 687 
     | 
    
         
            +
             
     | 
| 
      
 688 
     | 
    
         
            +
                include Synchronize
         
     | 
| 
      
 689 
     | 
    
         
            +
             
     | 
| 
      
 690 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 691 
     | 
    
         
            +
                attr_reader :_pool
         
     | 
| 
      
 692 
     | 
    
         
            +
             
     | 
| 
      
 693 
     | 
    
         
            +
                # self が has-a 関係で包含するオブジェクト
         
     | 
| 
      
 694 
     | 
    
         
            +
                #
         
     | 
| 
      
 695 
     | 
    
         
            +
                # @return [Array<When::Parts::Resource>]
         
     | 
| 
      
 696 
     | 
    
         
            +
                #
         
     | 
| 
      
 697 
     | 
    
         
            +
                attr_accessor :child
         
     | 
| 
      
 698 
     | 
    
         
            +
                private :child=
         
     | 
| 
      
 699 
     | 
    
         
            +
             
     | 
| 
      
 700 
     | 
    
         
            +
                #
         
     | 
| 
      
 701 
     | 
    
         
            +
                # Resource包含階層で使用する namespace
         
     | 
| 
      
 702 
     | 
    
         
            +
                #
         
     | 
| 
      
 703 
     | 
    
         
            +
                #   When::BasicTypes::M17n の生成に使用する namespace を定義する。
         
     | 
| 
      
 704 
     | 
    
         
            +
                #   RFC 5545 に対する拡張である。
         
     | 
| 
      
 705 
     | 
    
         
            +
                #   xml で記述する場合には、本ライブラリ以外でも namespace を定義している。
         
     | 
| 
      
 706 
     | 
    
         
            +
                #
         
     | 
| 
      
 707 
     | 
    
         
            +
                # @return [Hash] { prefix => prefix文字列 }
         
     | 
| 
      
 708 
     | 
    
         
            +
                #
         
     | 
| 
      
 709 
     | 
    
         
            +
                attr_reader :namespace
         
     | 
| 
      
 710 
     | 
    
         
            +
             
     | 
| 
      
 711 
     | 
    
         
            +
                #
         
     | 
| 
      
 712 
     | 
    
         
            +
                # Resource包含階層で使用する locale
         
     | 
| 
      
 713 
     | 
    
         
            +
                #
         
     | 
| 
      
 714 
     | 
    
         
            +
                #   When::BasicTypes::M17n の生成に使用する locale を定義する。
         
     | 
| 
      
 715 
     | 
    
         
            +
                #   RFC 5545 に対する拡張である。
         
     | 
| 
      
 716 
     | 
    
         
            +
                #
         
     | 
| 
      
 717 
     | 
    
         
            +
                # @return [Array<String>]
         
     | 
| 
      
 718 
     | 
    
         
            +
                #
         
     | 
| 
      
 719 
     | 
    
         
            +
                attr_reader :locale
         
     | 
| 
      
 720 
     | 
    
         
            +
             
     | 
| 
      
 721 
     | 
    
         
            +
                # strftime で有効な locale
         
     | 
| 
      
 722 
     | 
    
         
            +
                #
         
     | 
| 
      
 723 
     | 
    
         
            +
                # @return [Array<String>]
         
     | 
| 
      
 724 
     | 
    
         
            +
                #
         
     | 
| 
      
 725 
     | 
    
         
            +
                attr_reader :keys
         
     | 
| 
      
 726 
     | 
    
         
            +
             
     | 
| 
      
 727 
     | 
    
         
            +
                # オブジェクトの IRI
         
     | 
| 
      
 728 
     | 
    
         
            +
                #
         
     | 
| 
      
 729 
     | 
    
         
            +
                # @param [Boolean] prefix true ならIRI の先頭部分を簡約表現にする
         
     | 
| 
      
 730 
     | 
    
         
            +
                #
         
     | 
| 
      
 731 
     | 
    
         
            +
                # @return [Sring]
         
     | 
| 
      
 732 
     | 
    
         
            +
                #
         
     | 
| 
      
 733 
     | 
    
         
            +
                def iri(prefix=false)
         
     | 
| 
      
 734 
     | 
    
         
            +
                  unless @iri
         
     | 
| 
      
 735 
     | 
    
         
            +
                    root = @_pool['..']
         
     | 
| 
      
 736 
     | 
    
         
            +
                    path = root.instance_of?(String) ? root : label.to_s
         
     | 
| 
      
 737 
     | 
    
         
            +
                    if root.respond_to?(:iri)
         
     | 
| 
      
 738 
     | 
    
         
            +
                      root_iri = root.iri
         
     | 
| 
      
 739 
     | 
    
         
            +
                      path = root_iri + '::' + path if root_iri
         
     | 
| 
      
 740 
     | 
    
         
            +
                    end
         
     | 
| 
      
 741 
     | 
    
         
            +
                    @iri = path
         
     | 
| 
      
 742 
     | 
    
         
            +
                  end
         
     | 
| 
      
 743 
     | 
    
         
            +
                  prefix ? Resource._simplify_path(@iri) : @iri
         
     | 
| 
      
 744 
     | 
    
         
            +
                end
         
     | 
| 
      
 745 
     | 
    
         
            +
             
     | 
| 
      
 746 
     | 
    
         
            +
                # IRI または child の番号によるオブジェクト参照
         
     | 
| 
      
 747 
     | 
    
         
            +
                #
         
     | 
| 
      
 748 
     | 
    
         
            +
                # @param [String]  iri オブジェクトの IRI
         
     | 
| 
      
 749 
     | 
    
         
            +
                # @param [Numeric] iri child の index
         
     | 
| 
      
 750 
     | 
    
         
            +
                #
         
     | 
| 
      
 751 
     | 
    
         
            +
                # @return [When::parts::Resource]
         
     | 
| 
      
 752 
     | 
    
         
            +
                #
         
     | 
| 
      
 753 
     | 
    
         
            +
                def [](iri)
         
     | 
| 
      
 754 
     | 
    
         
            +
                  case iri
         
     | 
| 
      
 755 
     | 
    
         
            +
                  when Numeric
         
     | 
| 
      
 756 
     | 
    
         
            +
                    return child[iri * 1]
         
     | 
| 
      
 757 
     | 
    
         
            +
                  when String
         
     | 
| 
      
 758 
     | 
    
         
            +
                    obj = self
         
     | 
| 
      
 759 
     | 
    
         
            +
                    Resource._encode(iri).split(/::/).each do |label|
         
     | 
| 
      
 760 
     | 
    
         
            +
                      return obj.child if label == '*'
         
     | 
| 
      
 761 
     | 
    
         
            +
                      if obj == Resource
         
     | 
| 
      
 762 
     | 
    
         
            +
                        obj = Resource._instance(Resource._decode(label))
         
     | 
| 
      
 763 
     | 
    
         
            +
                      else
         
     | 
| 
      
 764 
     | 
    
         
            +
                        case label
         
     | 
| 
      
 765 
     | 
    
         
            +
                        when ''  ; obj = Resource
         
     | 
| 
      
 766 
     | 
    
         
            +
                        when '.' # obj = obj
         
     | 
| 
      
 767 
     | 
    
         
            +
                        else     ; obj = obj._pool[Resource._decode(label)]
         
     | 
| 
      
 768 
     | 
    
         
            +
                        end
         
     | 
| 
      
 769 
     | 
    
         
            +
                      end
         
     | 
| 
      
 770 
     | 
    
         
            +
                      raise ArgumentError, "IRI not found: #{iri}" unless obj
         
     | 
| 
      
 771 
     | 
    
         
            +
                    end
         
     | 
| 
      
 772 
     | 
    
         
            +
                    return obj
         
     | 
| 
      
 773 
     | 
    
         
            +
                  else
         
     | 
| 
      
 774 
     | 
    
         
            +
                    super(iri)
         
     | 
| 
      
 775 
     | 
    
         
            +
                    #raise ArgumentError, "IRI not found: #{iri}"
         
     | 
| 
      
 776 
     | 
    
         
            +
                  end
         
     | 
| 
      
 777 
     | 
    
         
            +
                end
         
     | 
| 
      
 778 
     | 
    
         
            +
             
     | 
| 
      
 779 
     | 
    
         
            +
                # self を直接に包含するオブジェクト
         
     | 
| 
      
 780 
     | 
    
         
            +
                #
         
     | 
| 
      
 781 
     | 
    
         
            +
                # @return [When::Parts::Resource]
         
     | 
| 
      
 782 
     | 
    
         
            +
                #
         
     | 
| 
      
 783 
     | 
    
         
            +
                def parent
         
     | 
| 
      
 784 
     | 
    
         
            +
                  @_pool['..'].kind_of?(Resource) ? @_pool['..'] : nil
         
     | 
| 
      
 785 
     | 
    
         
            +
                end
         
     | 
| 
      
 786 
     | 
    
         
            +
             
     | 
| 
      
 787 
     | 
    
         
            +
                # self を包含するオブジェクト階層
         
     | 
| 
      
 788 
     | 
    
         
            +
                #
         
     | 
| 
      
 789 
     | 
    
         
            +
                # @param [Class] klass 階層を遡るクラス
         
     | 
| 
      
 790 
     | 
    
         
            +
                #
         
     | 
| 
      
 791 
     | 
    
         
            +
                # @return [When::Parts::Resource]
         
     | 
| 
      
 792 
     | 
    
         
            +
                #
         
     | 
| 
      
 793 
     | 
    
         
            +
                def hierarchy(klass=self.class)
         
     | 
| 
      
 794 
     | 
    
         
            +
                  hierarchy = []
         
     | 
| 
      
 795 
     | 
    
         
            +
                  parent    = self
         
     | 
| 
      
 796 
     | 
    
         
            +
                  while parent.kind_of?(klass)
         
     | 
| 
      
 797 
     | 
    
         
            +
                    hierarchy << parent
         
     | 
| 
      
 798 
     | 
    
         
            +
                    parent = parent.parent
         
     | 
| 
      
 799 
     | 
    
         
            +
                  end
         
     | 
| 
      
 800 
     | 
    
         
            +
                  hierarchy.reverse
         
     | 
| 
      
 801 
     | 
    
         
            +
                end
         
     | 
| 
      
 802 
     | 
    
         
            +
             
     | 
| 
      
 803 
     | 
    
         
            +
                # self が other を包含するか
         
     | 
| 
      
 804 
     | 
    
         
            +
                #
         
     | 
| 
      
 805 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
      
 806 
     | 
    
         
            +
                #   [ true  - 包含する   ]
         
     | 
| 
      
 807 
     | 
    
         
            +
                #   [ false - 包含しない ]
         
     | 
| 
      
 808 
     | 
    
         
            +
                #
         
     | 
| 
      
 809 
     | 
    
         
            +
                def include?(other)
         
     | 
| 
      
 810 
     | 
    
         
            +
                  c = other
         
     | 
| 
      
 811 
     | 
    
         
            +
                  while c.kind_of?(Resource)
         
     | 
| 
      
 812 
     | 
    
         
            +
                    return true if c.equal?(self)
         
     | 
| 
      
 813 
     | 
    
         
            +
                    c = c.parent
         
     | 
| 
      
 814 
     | 
    
         
            +
                  end
         
     | 
| 
      
 815 
     | 
    
         
            +
                  return false
         
     | 
| 
      
 816 
     | 
    
         
            +
                end
         
     | 
| 
      
 817 
     | 
    
         
            +
             
     | 
| 
      
 818 
     | 
    
         
            +
                # other が self を包含するか
         
     | 
| 
      
 819 
     | 
    
         
            +
                #
         
     | 
| 
      
 820 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
      
 821 
     | 
    
         
            +
                #   [ true  - 包含される   ]
         
     | 
| 
      
 822 
     | 
    
         
            +
                #   [ false - 包含されない ]
         
     | 
| 
      
 823 
     | 
    
         
            +
                #
         
     | 
| 
      
 824 
     | 
    
         
            +
                def included?(other)
         
     | 
| 
      
 825 
     | 
    
         
            +
                  other.include?(self)
         
     | 
| 
      
 826 
     | 
    
         
            +
                end
         
     | 
| 
      
 827 
     | 
    
         
            +
             
     | 
| 
      
 828 
     | 
    
         
            +
                # 前のオブジェクト
         
     | 
| 
      
 829 
     | 
    
         
            +
                #
         
     | 
| 
      
 830 
     | 
    
         
            +
                # @return [When::Parts::Resource]
         
     | 
| 
      
 831 
     | 
    
         
            +
                #
         
     | 
| 
      
 832 
     | 
    
         
            +
                def prev
         
     | 
| 
      
 833 
     | 
    
         
            +
                  c = self
         
     | 
| 
      
 834 
     | 
    
         
            +
                  c = c.child[0] while c.child && c.child.size > 0
         
     | 
| 
      
 835 
     | 
    
         
            +
                  c = c._pool['.<-']
         
     | 
| 
      
 836 
     | 
    
         
            +
                  c = c.child[-1] while c && c.child && c.child.size > 0
         
     | 
| 
      
 837 
     | 
    
         
            +
                  c
         
     | 
| 
      
 838 
     | 
    
         
            +
                end
         
     | 
| 
      
 839 
     | 
    
         
            +
             
     | 
| 
      
 840 
     | 
    
         
            +
                # 次のオブジェクト
         
     | 
| 
      
 841 
     | 
    
         
            +
                #
         
     | 
| 
      
 842 
     | 
    
         
            +
                # @return [When::Parts::Resource]
         
     | 
| 
      
 843 
     | 
    
         
            +
                #
         
     | 
| 
      
 844 
     | 
    
         
            +
                def next
         
     | 
| 
      
 845 
     | 
    
         
            +
                  c = self
         
     | 
| 
      
 846 
     | 
    
         
            +
                  c = c.child[0] while c.child && c.child.size > 0
         
     | 
| 
      
 847 
     | 
    
         
            +
                  c._pool['.->']
         
     | 
| 
      
 848 
     | 
    
         
            +
                end
         
     | 
| 
      
 849 
     | 
    
         
            +
                alias :succ :next
         
     | 
| 
      
 850 
     | 
    
         
            +
             
     | 
| 
      
 851 
     | 
    
         
            +
                # オブジェクト包含階層の末端か?
         
     | 
| 
      
 852 
     | 
    
         
            +
                #
         
     | 
| 
      
 853 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
      
 854 
     | 
    
         
            +
                #   [ true  - IRIが付与された他のオブジェクトを包含していない ]
         
     | 
| 
      
 855 
     | 
    
         
            +
                #   [ false - IRIが付与された他のオブジェクトを包含している   ]
         
     | 
| 
      
 856 
     | 
    
         
            +
                #
         
     | 
| 
      
 857 
     | 
    
         
            +
                def leaf?
         
     | 
| 
      
 858 
     | 
    
         
            +
                  !@child || (@child.length==0)
         
     | 
| 
      
 859 
     | 
    
         
            +
                end
         
     | 
| 
      
 860 
     | 
    
         
            +
             
     | 
| 
      
 861 
     | 
    
         
            +
                # IRIが付与されているか?
         
     | 
| 
      
 862 
     | 
    
         
            +
                #
         
     | 
| 
      
 863 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
      
 864 
     | 
    
         
            +
                #   [ true  - IRIが付与されている   ]
         
     | 
| 
      
 865 
     | 
    
         
            +
                #   [ false - IRIが付与されていない ]
         
     | 
| 
      
 866 
     | 
    
         
            +
                #
         
     | 
| 
      
 867 
     | 
    
         
            +
                def registered?
         
     | 
| 
      
 868 
     | 
    
         
            +
                  leaf = self
         
     | 
| 
      
 869 
     | 
    
         
            +
                  while leaf._pool && leaf._pool['..'].respond_to?(:_pool)
         
     | 
| 
      
 870 
     | 
    
         
            +
                    root = leaf._pool['..']
         
     | 
| 
      
 871 
     | 
    
         
            +
                    return false unless leaf.equal?(root._pool[leaf.label])
         
     | 
| 
      
 872 
     | 
    
         
            +
                    leaf = root
         
     | 
| 
      
 873 
     | 
    
         
            +
                  end
         
     | 
| 
      
 874 
     | 
    
         
            +
                  Resource._pool.value?(leaf)
         
     | 
| 
      
 875 
     | 
    
         
            +
                end
         
     | 
| 
      
 876 
     | 
    
         
            +
             
     | 
| 
      
 877 
     | 
    
         
            +
                # When::BasicTypes::M17n の生成/参照
         
     | 
| 
      
 878 
     | 
    
         
            +
                #
         
     | 
| 
      
 879 
     | 
    
         
            +
                # @param [When::BasicTypes::M17n] source 処理を行わず、そのままsourceを返す
         
     | 
| 
      
 880 
     | 
    
         
            +
                # @param [String] source locale と 文字列の対応
         
     | 
| 
      
 881 
     | 
    
         
            +
                # @param [Array]  source 要素を個別に解釈して生成したオブジェクトのArrayを返す
         
     | 
| 
      
 882 
     | 
    
         
            +
                # @param [Hash]   namespace prefix の指定
         
     | 
| 
      
 883 
     | 
    
         
            +
                # @param [Array]  locale    locale の定義順序の指定
         
     | 
| 
      
 884 
     | 
    
         
            +
                # @param [Hash]   options (see {When::BasicTypes::M17n.new}[link:When/BasicTypes/M17n.html#method-c-new])
         
     | 
| 
      
 885 
     | 
    
         
            +
                #
         
     | 
| 
      
 886 
     | 
    
         
            +
                # @return [When::BasicTypes::M17n or Array<them>]
         
     | 
| 
      
 887 
     | 
    
         
            +
                #
         
     | 
| 
      
 888 
     | 
    
         
            +
                def m17n(source, namespace=nil, locale=nil, options={})
         
     | 
| 
      
 889 
     | 
    
         
            +
                  case source
         
     | 
| 
      
 890 
     | 
    
         
            +
                  when Array                  ; When::BasicTypes::M17n.new(source, namespace, locale, options)
         
     | 
| 
      
 891 
     | 
    
         
            +
                  when When::BasicTypes::M17n ; source
         
     | 
| 
      
 892 
     | 
    
         
            +
                  when String
         
     | 
| 
      
 893 
     | 
    
         
            +
                    return self[$1] if source =~ /\A\s*\[((\.{1,2}|::)+[^\]]+)\]/
         
     | 
| 
      
 894 
     | 
    
         
            +
                    When::BasicTypes::M17n.new(source, namespace, locale, options)
         
     | 
| 
      
 895 
     | 
    
         
            +
                  else ; raise TypeError, "Invalid Type: #{source.class}"
         
     | 
| 
      
 896 
     | 
    
         
            +
                  end
         
     | 
| 
      
 897 
     | 
    
         
            +
                end
         
     | 
| 
      
 898 
     | 
    
         
            +
             
     | 
| 
      
 899 
     | 
    
         
            +
                # 子オブジェクトを順に取り出す enumerator
         
     | 
| 
      
 900 
     | 
    
         
            +
                #
         
     | 
| 
      
 901 
     | 
    
         
            +
                def enum_for
         
     | 
| 
      
 902 
     | 
    
         
            +
                  @child.enum_for
         
     | 
| 
      
 903 
     | 
    
         
            +
                end
         
     | 
| 
      
 904 
     | 
    
         
            +
                alias :to_enum :enum_for
         
     | 
| 
      
 905 
     | 
    
         
            +
             
     | 
| 
      
 906 
     | 
    
         
            +
                # Enumerator 生成のダミー
         
     | 
| 
      
 907 
     | 
    
         
            +
                #
         
     | 
| 
      
 908 
     | 
    
         
            +
                # @param [Object] other
         
     | 
| 
      
 909 
     | 
    
         
            +
                #
         
     | 
| 
      
 910 
     | 
    
         
            +
                # @return [Enumerator]
         
     | 
| 
      
 911 
     | 
    
         
            +
                #
         
     | 
| 
      
 912 
     | 
    
         
            +
                def ^(other)
         
     | 
| 
      
 913 
     | 
    
         
            +
                  return nil
         
     | 
| 
      
 914 
     | 
    
         
            +
                end
         
     | 
| 
      
 915 
     | 
    
         
            +
             
     | 
| 
      
 916 
     | 
    
         
            +
                # 順次実行
         
     | 
| 
      
 917 
     | 
    
         
            +
                #
         
     | 
| 
      
 918 
     | 
    
         
            +
                # @param [Array] args  各サブクラスの enum_for にそのまま渡す
         
     | 
| 
      
 919 
     | 
    
         
            +
                # @param [Block] block 実行するブロック
         
     | 
| 
      
 920 
     | 
    
         
            +
                #
         
     | 
| 
      
 921 
     | 
    
         
            +
                # @return [Enumerator]
         
     | 
| 
      
 922 
     | 
    
         
            +
                #
         
     | 
| 
      
 923 
     | 
    
         
            +
                def each(*args, &block)
         
     | 
| 
      
 924 
     | 
    
         
            +
                  enum = enum_for(*args)
         
     | 
| 
      
 925 
     | 
    
         
            +
                  return enum unless block
         
     | 
| 
      
 926 
     | 
    
         
            +
                  enum.each(&block)
         
     | 
| 
      
 927 
     | 
    
         
            +
                end
         
     | 
| 
      
 928 
     | 
    
         
            +
             
     | 
| 
      
 929 
     | 
    
         
            +
                # map, collect の再定義
         
     | 
| 
      
 930 
     | 
    
         
            +
                #
         
     | 
| 
      
 931 
     | 
    
         
            +
                # has-a 関係の子 Resource に対して map/collect を行う
         
     | 
| 
      
 932 
     | 
    
         
            +
                #
         
     | 
| 
      
 933 
     | 
    
         
            +
                # @param [Block] block 実行するブロック
         
     | 
| 
      
 934 
     | 
    
         
            +
                #
         
     | 
| 
      
 935 
     | 
    
         
            +
                # @return [Array]
         
     | 
| 
      
 936 
     | 
    
         
            +
                #
         
     | 
| 
      
 937 
     | 
    
         
            +
                def map(&block)
         
     | 
| 
      
 938 
     | 
    
         
            +
                  @child.map(&block)
         
     | 
| 
      
 939 
     | 
    
         
            +
                end
         
     | 
| 
      
 940 
     | 
    
         
            +
                alias :collect :map
         
     | 
| 
      
 941 
     | 
    
         
            +
             
     | 
| 
      
 942 
     | 
    
         
            +
                protected
         
     | 
| 
      
 943 
     | 
    
         
            +
             
     | 
| 
      
 944 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 945 
     | 
    
         
            +
                def pool_keys
         
     | 
| 
      
 946 
     | 
    
         
            +
                  _pool.keys
         
     | 
| 
      
 947 
     | 
    
         
            +
                end
         
     | 
| 
      
 948 
     | 
    
         
            +
             
     | 
| 
      
 949 
     | 
    
         
            +
                private
         
     | 
| 
      
 950 
     | 
    
         
            +
             
     | 
| 
      
 951 
     | 
    
         
            +
                # 属性の設定
         
     | 
| 
      
 952 
     | 
    
         
            +
                def _attributes(args)
         
     | 
| 
      
 953 
     | 
    
         
            +
                  options =_get_options(args)
         
     | 
| 
      
 954 
     | 
    
         
            +
                  _set_variables(options)
         
     | 
| 
      
 955 
     | 
    
         
            +
                  return args, options
         
     | 
| 
      
 956 
     | 
    
         
            +
                end
         
     | 
| 
      
 957 
     | 
    
         
            +
             
     | 
| 
      
 958 
     | 
    
         
            +
                # option の読み出し
         
     | 
| 
      
 959 
     | 
    
         
            +
                def _get_options(args)
         
     | 
| 
      
 960 
     | 
    
         
            +
                  options = args[-1].kind_of?(Hash) ? args.pop : {}
         
     | 
| 
      
 961 
     | 
    
         
            +
                  @_pool  = {}
         
     | 
| 
      
 962 
     | 
    
         
            +
                  @_pool['..'] = options['..'] if (options['..'])
         
     | 
| 
      
 963 
     | 
    
         
            +
             
     | 
| 
      
 964 
     | 
    
         
            +
                  # 配下のオブジェクトの生成と関連付け
         
     | 
| 
      
 965 
     | 
    
         
            +
                  if (options.key?('.'))
         
     | 
| 
      
 966 
     | 
    
         
            +
                    _child(options)
         
     | 
| 
      
 967 
     | 
    
         
            +
                  end
         
     | 
| 
      
 968 
     | 
    
         
            +
             
     | 
| 
      
 969 
     | 
    
         
            +
                  options
         
     | 
| 
      
 970 
     | 
    
         
            +
                end
         
     | 
| 
      
 971 
     | 
    
         
            +
             
     | 
| 
      
 972 
     | 
    
         
            +
                # 変数の設定
         
     | 
| 
      
 973 
     | 
    
         
            +
                def _set_variables(options)
         
     | 
| 
      
 974 
     | 
    
         
            +
                  @options = options[:options] || {} if options.key?(:options)
         
     | 
| 
      
 975 
     | 
    
         
            +
                  options.each_pair do |key,value|
         
     | 
| 
      
 976 
     | 
    
         
            +
                    unless (key =~ /\Aoptions$|^\.|^[A-Z]/)
         
     | 
| 
      
 977 
     | 
    
         
            +
                      case "#{key}"
         
     | 
| 
      
 978 
     | 
    
         
            +
                      when 'namespace' ; value = When::Locale._namespace(value)
         
     | 
| 
      
 979 
     | 
    
         
            +
                      when 'locale'    ; value = When::Locale._locale(value)
         
     | 
| 
      
 980 
     | 
    
         
            +
                      end
         
     | 
| 
      
 981 
     | 
    
         
            +
                      instance_variable_set("@#{key}", value)
         
     | 
| 
      
 982 
     | 
    
         
            +
                    end
         
     | 
| 
      
 983 
     | 
    
         
            +
                  end
         
     | 
| 
      
 984 
     | 
    
         
            +
                end
         
     | 
| 
      
 985 
     | 
    
         
            +
             
     | 
| 
      
 986 
     | 
    
         
            +
                # 配下のオブジェクトの生成
         
     | 
| 
      
 987 
     | 
    
         
            +
                def _child(options)
         
     | 
| 
      
 988 
     | 
    
         
            +
                  @child           = []
         
     | 
| 
      
 989 
     | 
    
         
            +
                  query            = options.dup
         
     | 
| 
      
 990 
     | 
    
         
            +
                  options['..']    = self
         
     | 
| 
      
 991 
     | 
    
         
            +
                  leaves           = options.delete('.').map {|leaf| Resource._parse(leaf)}
         
     | 
| 
      
 992 
     | 
    
         
            +
                  key_list         = []
         
     | 
| 
      
 993 
     | 
    
         
            +
                  properties       = {}
         
     | 
| 
      
 994 
     | 
    
         
            +
                  label_candidates = nil
         
     | 
| 
      
 995 
     | 
    
         
            +
             
     | 
| 
      
 996 
     | 
    
         
            +
                  # ContentLine の処理(namespace, locale, altidの前処理)
         
     | 
| 
      
 997 
     | 
    
         
            +
                  leaves.each do |content|
         
     | 
| 
      
 998 
     | 
    
         
            +
                    next unless content.kind_of?(ContentLine)
         
     | 
| 
      
 999 
     | 
    
         
            +
                    key   = content.predicate
         
     | 
| 
      
 1000 
     | 
    
         
            +
                    value = content.object
         
     | 
| 
      
 1001 
     | 
    
         
            +
                    next options.delete(key) unless value
         
     | 
| 
      
 1002 
     | 
    
         
            +
                    case key
         
     | 
| 
      
 1003 
     | 
    
         
            +
                    when 'namespace'
         
     | 
| 
      
 1004 
     | 
    
         
            +
                      options[key] ||= {}
         
     | 
| 
      
 1005 
     | 
    
         
            +
                      if content.attribute['altid']
         
     | 
| 
      
 1006 
     | 
    
         
            +
                        options[key][content.attribute['prefix'].object] = content.object
         
     | 
| 
      
 1007 
     | 
    
         
            +
                      else
         
     | 
| 
      
 1008 
     | 
    
         
            +
                        options[key] = options[key].update(When::Locale._namespace(value))
         
     | 
| 
      
 1009 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1010 
     | 
    
         
            +
                    when 'locale'
         
     | 
| 
      
 1011 
     | 
    
         
            +
                      options[key] = When::Locale._locale(value)
         
     | 
| 
      
 1012 
     | 
    
         
            +
                    else
         
     | 
| 
      
 1013 
     | 
    
         
            +
                      _parse_altid(properties, content)
         
     | 
| 
      
 1014 
     | 
    
         
            +
                      key_list << key unless key_list.include?(key)
         
     | 
| 
      
 1015 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1016 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1017 
     | 
    
         
            +
             
     | 
| 
      
 1018 
     | 
    
         
            +
                  # ContentLine の処理(一般)
         
     | 
| 
      
 1019 
     | 
    
         
            +
                  key_list.each do |key|
         
     | 
| 
      
 1020 
     | 
    
         
            +
                    content = properties[key][0]
         
     | 
| 
      
 1021 
     | 
    
         
            +
                    value   = content.same_altid ? When::BasicTypes::M17n.new(content, options['namespace'], []) : content.object
         
     | 
| 
      
 1022 
     | 
    
         
            +
                    value   = When::BasicTypes::M17n.new(value, nil, nil, options) if value.instance_of?(String) && value =~ /\A\s*\[/
         
     | 
| 
      
 1023 
     | 
    
         
            +
                    @_pool[value.to_s] = value if value.kind_of?(When::BasicTypes::M17n)
         
     | 
| 
      
 1024 
     | 
    
         
            +
                    if content.marked || key == self.class::LabelProperty
         
     | 
| 
      
 1025 
     | 
    
         
            +
                      @label = value
         
     | 
| 
      
 1026 
     | 
    
         
            +
                    else
         
     | 
| 
      
 1027 
     | 
    
         
            +
                      options[key] = value
         
     | 
| 
      
 1028 
     | 
    
         
            +
                      label_candidates ||= value
         
     | 
| 
      
 1029 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1030 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1031 
     | 
    
         
            +
             
     | 
| 
      
 1032 
     | 
    
         
            +
                  # 代表ラベルの設定
         
     | 
| 
      
 1033 
     | 
    
         
            +
                  unless @label
         
     | 
| 
      
 1034 
     | 
    
         
            +
                    raise ArgumentError, "label attribute not found: #{options['.']}" unless label_candidates
         
     | 
| 
      
 1035 
     | 
    
         
            +
                    @label = label_candidates
         
     | 
| 
      
 1036 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1037 
     | 
    
         
            +
             
     | 
| 
      
 1038 
     | 
    
         
            +
                  # Array の処理(子オブジェクトの生成)
         
     | 
| 
      
 1039 
     | 
    
         
            +
                  leaves.each do |content|
         
     | 
| 
      
 1040 
     | 
    
         
            +
                    next unless content.kind_of?(Array)
         
     | 
| 
      
 1041 
     | 
    
         
            +
                    if content[0].kind_of?(Class)
         
     | 
| 
      
 1042 
     | 
    
         
            +
                      list = []
         
     | 
| 
      
 1043 
     | 
    
         
            +
                      content.each do |e|
         
     | 
| 
      
 1044 
     | 
    
         
            +
                        if e.kind_of?(Hash)
         
     | 
| 
      
 1045 
     | 
    
         
            +
                          list += e.keys.map {|key| Resource::ContentLine.new(key, e[key])}
         
     | 
| 
      
 1046 
     | 
    
         
            +
                        else
         
     | 
| 
      
 1047 
     | 
    
         
            +
                          list << e
         
     | 
| 
      
 1048 
     | 
    
         
            +
                        end
         
     | 
| 
      
 1049 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1050 
     | 
    
         
            +
                      options['.'] = list
         
     | 
| 
      
 1051 
     | 
    
         
            +
                      @child << content[0].new(options.dup)
         
     | 
| 
      
 1052 
     | 
    
         
            +
                    else
         
     | 
| 
      
 1053 
     | 
    
         
            +
                      options.delete('.')
         
     | 
| 
      
 1054 
     | 
    
         
            +
                      @child << self.class.new(*(content + [options]))
         
     | 
| 
      
 1055 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1056 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1057 
     | 
    
         
            +
             
     | 
| 
      
 1058 
     | 
    
         
            +
                  # options の更新
         
     | 
| 
      
 1059 
     | 
    
         
            +
                  options.update(query)
         
     | 
| 
      
 1060 
     | 
    
         
            +
                end
         
     | 
| 
      
 1061 
     | 
    
         
            +
             
     | 
| 
      
 1062 
     | 
    
         
            +
                # ALTIDを持つ ContentLine の解析
         
     | 
| 
      
 1063 
     | 
    
         
            +
                def _parse_altid(properties, content)
         
     | 
| 
      
 1064 
     | 
    
         
            +
                  key = content.predicate
         
     | 
| 
      
 1065 
     | 
    
         
            +
                  properties[key] ||= []
         
     | 
| 
      
 1066 
     | 
    
         
            +
                  if content.attribute['altid']
         
     | 
| 
      
 1067 
     | 
    
         
            +
                    found = false
         
     | 
| 
      
 1068 
     | 
    
         
            +
                    (0...properties[key].length).to_a.each do |i|
         
     | 
| 
      
 1069 
     | 
    
         
            +
                      prev = properties[key][i]
         
     | 
| 
      
 1070 
     | 
    
         
            +
                      if prev.attribute['altid'] && prev.attribute['altid'].object == content.attribute['altid'].object
         
     | 
| 
      
 1071 
     | 
    
         
            +
                        content.same_altid      = prev
         
     | 
| 
      
 1072 
     | 
    
         
            +
                        properties[key][i] = content
         
     | 
| 
      
 1073 
     | 
    
         
            +
                        found = true
         
     | 
| 
      
 1074 
     | 
    
         
            +
                        break
         
     | 
| 
      
 1075 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1076 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1077 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1078 
     | 
    
         
            +
                  properties[key] << content unless found
         
     | 
| 
      
 1079 
     | 
    
         
            +
                end
         
     | 
| 
      
 1080 
     | 
    
         
            +
             
     | 
| 
      
 1081 
     | 
    
         
            +
                # 配下のオブジェクトの前後関係の設定
         
     | 
| 
      
 1082 
     | 
    
         
            +
                def _sequence
         
     | 
| 
      
 1083 
     | 
    
         
            +
                  return unless @child
         
     | 
| 
      
 1084 
     | 
    
         
            +
                  prev = @_pool['..'].child[-1] if @_pool['..'].respond_to?(:child)
         
     | 
| 
      
 1085 
     | 
    
         
            +
                  @child.each do |v|
         
     | 
| 
      
 1086 
     | 
    
         
            +
                    if prev
         
     | 
| 
      
 1087 
     | 
    
         
            +
                      v._pool['.<-'] = prev
         
     | 
| 
      
 1088 
     | 
    
         
            +
                      prev._pool['.->'] = v
         
     | 
| 
      
 1089 
     | 
    
         
            +
                      while (prev.child && prev.child[-1]) do
         
     | 
| 
      
 1090 
     | 
    
         
            +
                        prev = prev.child[-1]
         
     | 
| 
      
 1091 
     | 
    
         
            +
                        prev._pool['.->'] = v
         
     | 
| 
      
 1092 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1093 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1094 
     | 
    
         
            +
                    @_pool[v.label.to_s] = v
         
     | 
| 
      
 1095 
     | 
    
         
            +
                    prev = v
         
     | 
| 
      
 1096 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1097 
     | 
    
         
            +
                end
         
     | 
| 
      
 1098 
     | 
    
         
            +
             
     | 
| 
      
 1099 
     | 
    
         
            +
                alias :__method_missing :method_missing
         
     | 
| 
      
 1100 
     | 
    
         
            +
             
     | 
| 
      
 1101 
     | 
    
         
            +
                # その他のメソッド
         
     | 
| 
      
 1102 
     | 
    
         
            +
                #   When::Parts::Resource で定義されていないメソッドは
         
     | 
| 
      
 1103 
     | 
    
         
            +
                #   処理を @child (type: Array) に委譲する
         
     | 
| 
      
 1104 
     | 
    
         
            +
                #
         
     | 
| 
      
 1105 
     | 
    
         
            +
                def method_missing(name, *args, &block)
         
     | 
| 
      
 1106 
     | 
    
         
            +
                  return __method_missing(name, *args, &block) if When::Parts::MethodCash::Escape.key?(name)
         
     | 
| 
      
 1107 
     | 
    
         
            +
                  self.class.module_eval %Q{
         
     | 
| 
      
 1108 
     | 
    
         
            +
                    def #{name}(*args, &block)
         
     | 
| 
      
 1109 
     | 
    
         
            +
                      @child.send("#{name}", *args, &block)
         
     | 
| 
      
 1110 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1111 
     | 
    
         
            +
                  } unless When::Parts::MethodCash.escape(name)
         
     | 
| 
      
 1112 
     | 
    
         
            +
                  @child.send(name, *args, &block)
         
     | 
| 
      
 1113 
     | 
    
         
            +
                end
         
     | 
| 
      
 1114 
     | 
    
         
            +
              end
         
     | 
| 
      
 1115 
     | 
    
         
            +
            end
         
     |