Module: BEL::Script
- Defined in:
- lib/bel/script.rb
Defined Under Namespace
Constant Summary collapse
- MAX_LENGTH =
128K
1024 * 128
Class Method Summary collapse
-
.parse(content, namespaces = {}) ⇒ Enumerator
prefixes in BEL statements; defaults to empty meaning use the DEFINE NAMESPACE definitions in the content.
-
.parse_chunked(io, namespaces = {}, chunk_length = MAX_LENGTH) ⇒ Enumerator
prefixes in BEL statements; defaults to empty meaning use the DEFINE NAMESPACE definitions in the content.
Class Method Details
.parse(content, namespaces = {}) ⇒ Enumerator
prefixes in BEL statements; defaults to empty meaning use the DEFINE NAMESPACE definitions in the content
44015 44016 44017 44018 44019 44020 44021 44022 44023 44024 44025 44026 44027 44028 44029 44030 44031 44032 44033 44034 44035 44036 44037 44038 44039 44040 44041 44042 44043 44044 44045 |
# File 'lib/bel/script.rb', line 44015 def parse(content, namespaces = {}) return nil unless content parser = if content.is_a? String if !content.end_with?("\n") content << "\n" end Parser.new(content, namespaces) elsif content.respond_to? :read IOParser.new(content, namespaces, MAX_LENGTH) else nil end unless parser fail ArgumentError, "content: expected string or io-like" end if block_given? parser.each do |obj| yield obj end else if parser.respond_to? :lazy parser.lazy else parser end end end |
.parse_chunked(io, namespaces = {}, chunk_length = MAX_LENGTH) ⇒ Enumerator
prefixes in BEL statements; defaults to empty meaning use the DEFINE NAMESPACE definitions in the content
44059 44060 44061 44062 44063 44064 44065 44066 44067 44068 44069 44070 44071 44072 44073 44074 44075 44076 44077 44078 44079 44080 44081 44082 44083 44084 |
# File 'lib/bel/script.rb', line 44059 def parse_chunked(io, namespaces = {}, chunk_length = MAX_LENGTH) parser = if io.is_a? String parse(io, namespaces) elsif io.respond_to? :read IOParser.new(io, namespaces, chunk_length) else nil end unless parser fail ArgumentError, "content: expected string or io-like" end if block_given? parser.each do |obj| yield obj end else if parser.respond_to? :lazy parser.lazy else parser end end end |