openstudiocore/src/cli/embedded_help.rb
# ":" is our root path to the embedded file system
# make sure it is in the ruby load path
":" is our root path to the embedded file system
make sure it is in the ruby load path
" : " is our root path to the embedded file system make sure it is in the ruby load path
def open(name, *args)
    if name.to_s.chars.first == ':' then
      absolute_path = OpenStudio.get_absolute_path(name)
      if EmbeddedScripting::hasFile(absolute_path) then
        string = EmbeddedScripting::getFileAsString(absolute_path)
        if block_given?
          io = StringIO.open(string)
          begin
            result = yield(io)
          ensure
            io.close
          end
          return result
        else
          return StringIO.open(string)
        end
      else
        if block_given?
          io = StringIO.open("")
          begin
            result = yield(io)
          ensure
            io.close
          end
          return result
        else
          return ""
        end
      end
    end    
    if block_given?
      io = original_open(name, *args)
      begin
        result = yield(io)
      ensure
        io.close
      end
      return result
    else
      return original_open(name, *args)
    end
  end
def open ( name , * args ) if name . to_s . chars . first == ':' then absolute_path = OpenStudio . get_absolute_path ( name ) if EmbeddedScripting :: hasFile ( absolute_path ) then string = EmbeddedScripting :: getFileAsString ( absolute_path ) if block_given? io = StringIO . open ( string ) begin result = yield ( io ) ensure io . close end return result else return StringIO . open ( string ) end else if block_given? io = StringIO . open ( "" ) begin result = yield ( io ) ensure io . close end return result else return "" end end end if block_given? io = original_open ( name , * args ) begin result = yield ( io ) ensure io . close end return result else return original_open ( name , * args ) end end
":" is our root path to the embedded file system
make sure it is in the ruby load path
" : " is our root path to the embedded file system make sure it is in the ruby load path
#puts "I'm in Kernel.open!" #STDOUT.flush #puts "self.open(name, *args), name = #{name}, args = #{args}" #puts "absolute_path = #{absolute_path}" #puts "string = #{string}" # if a block is given, then a new IO is created and closed #puts "IO.open cannot find embedded file '#{absolute_path}' for '#{name}'" # if a block is given, then a new IO is created and closed # if a block is given, then a new IO is created and closed
name
<not_specific>
args
<not_specific>