From a91c976551f3df1a1f41e1b44d96597e64b09fa0 Mon Sep 17 00:00:00 2001 From: hachi8833 Date: Fri, 21 Jul 2017 08:09:43 +0900 Subject: [PATCH 1/3] Refactor parser.go first --- parser.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/parser.go b/parser.go index abdf2fe..c63b1b0 100644 --- a/parser.go +++ b/parser.go @@ -55,18 +55,25 @@ func classFromFile(filepath string) Class { // Continue only for general declarations if genDecl, ok := decl.(*ast.GenDecl); ok { for _, spec := range genDecl.Specs { + // Assign class line number if found - if tSpec, ok := spec.(*ast.TypeSpec); ok && class.MatchName(tSpec.Name.Name) { + tSpec, ok := spec.(*ast.TypeSpec) + if ok && class.MatchName(tSpec.Name.Name) { node := tSpec.Name class.Line = fset.Position(node.NamePos).Line } + // Assign class methods if found - if vSpec, ok := spec.(*ast.ValueSpec); ok && class.MatchClassMethods(vSpec.Names[0].Name) { - classMethods = vSpec - } - // Assign instance methods if found - if vSpec, ok := spec.(*ast.ValueSpec); ok && class.MatchInstanceMethods(vSpec.Names[0].Name) { - instanceMethods = vSpec + vSpec, ok := spec.(*ast.ValueSpec) + if ok { + if class.MatchClassMethods(vSpec.Names[0].Name) { + classMethods = vSpec + } + + // Assign instance methods if found + if class.MatchInstanceMethods(vSpec.Names[0].Name) { + instanceMethods = vSpec + } } } } From d014a693afe4a4860043e81b2cd7800109cfb0ff Mon Sep 17 00:00:00 2001 From: hachi8833 Date: Fri, 21 Jul 2017 09:13:18 +0900 Subject: [PATCH 2/3] Update parser to obtain instance/class methods from FuncDecl Update commit id --- docs/array.html | 532 +--------------------- docs/boolean.html | 157 +------ docs/{base_object.html => channel.html} | 20 +- docs/class.html | 299 ------------ docs/error.html | 33 +- docs/file.html | 428 +----------------- docs/hash.html | 120 ++--- docs/index.html | 16 +- docs/integer.html | 574 +----------------------- docs/method.html | 18 +- docs/null.html | 20 +- docs/object.html | 19 +- docs/range.html | 141 ++++++ docs/string.html | 396 ++-------------- parser.go | 29 +- settings.yml | 2 +- 16 files changed, 337 insertions(+), 2467 deletions(-) rename docs/{base_object.html => channel.html} (89%) delete mode 100755 docs/class.html create mode 100755 docs/range.html diff --git a/docs/array.html b/docs/array.html index 5f3499d..647b4eb 100755 --- a/docs/array.html +++ b/docs/array.html @@ -30,21 +30,15 @@ - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -120,522 +120,6 @@

    Class Methods

    Instance Methods


    -

    - # -

    - [] - - - -

    -

    -
    -
    -

    Retrieves an object in an array using Integer index. - The index starts from 0. It returns null if the given index is bigger than its size.

    - -
     a = [1, 2, 3, "a", "b", "c"]
    - a[0]  # => 1
    - a[3]  # => "a"
    - a[10] # => null
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - []= - - - -

    -

    -
    -
    -

    Assigns value to an array. It requires an index and a value as argument. - The array will expand if the assigned index is bigger than its size. - Returns the assigned value.

    - -
     a = []
    - a[0] = 10  # => 10
    - a[3] = 20  # => 20
    - a          # => [10, null, null, 20]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - length - - - -

    -

    -
    -
    -

    Returns the length of the array.

    - -
     [1, 2, 3].length # => 3
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - pop - - - -

    -

    -
    -
    -

    Removes the last element in the array and returns it.

    - -
     a = [1, 2, 3]
    - a.pop # => 3
    - a     # => [1, 2]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - push - - - -

    -

    -
    -
    -

    Appends the given object to the array and returns the array.

    - -
     a = [1, 2, 3]
    - a.push(4) # => [1, 2, 3, 4]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - shift - - - -

    -

    -
    -
    -

    Removes the first element in the array and returns it.

    - -
     a = [1, 2, 3]
    - a.shift # => 1
    - a       # => [2, 3]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - each - - - -

    -

    -
    -
    -

    Loop through each element with the given block.

    - -
     a = ["a", "b", "c"]
    -
    - a.each do |e|
    -   puts(e + e)
    - end
    - # => "aa"
    - # => "bb"
    - # => "cc"
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - each_index - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - map - - - -

    -

    -
    -
    -

    Loop through each element with the given block. Return a new array with each yield element.

    - -
     a = ["a", "b", "c"]
    -
    - a.map do |e|
    -   e + e
    - end
    - # => ["aa", "bb", "cc"]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - select - - - -

    -

    -
    -
    -

    Loop through each element with the given block. - Return a new array with each element that returns true from yield.

    - -
     a = [1, 2, 3, 4, 5]
    -
    - a.select do |e|
    -   e + 1 > 3
    - end
    - # => [3, 4, 5]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - at - - - -

    -

    -
    -
    -

    Retrieves an object in an array using the index argument. - It raises an error if index out of range.

    - -
     a = [1, 2, 3]
    - a.at(0)  # => 1
    - a.at(10) # => Error
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - clear - - - -

    -

    -
    -
    -

    Removes all elements in the array and returns an empty array.

    - -
     a = [1, 2, 3]
    - a.clear # => []
    - a       # => []
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - concat - - - -

    -

    -
    -
    -

    Appends any number of argument to the array.

    - -
     a = [1, 2, 3]
    - a.concat(4, 5, 6)
    - a # => [1, 2, 3, 4, 5, 6]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - count - - - -

    -

    -
    -
    -

    Loop through each element with the given block. - Return the sum of elements that return true from yield.

    - -
     a = [1, 2, 3, 4, 5]
    -
    - a.count do |e|
    -   e * 2 > 3
    - end
    - # => 4
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - rotate - - - -

    -

    -
    -
    -

    Returns a new array by putting the desired element as the first element. - Use integer index as an argument to retrieve the element.

    - -
     a = ["a", "b", "c", "d"]
    -
    - a.rotate    # => ["b", "c", "d", "a"]
    - a.rotate(2) # => ["c", "d", "a", "b"]
    - a.rotate(3) # => ["d", "a", "b", "c"]
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - first - - - -

    -

    -
    -
    -

    Returns the first element of the array.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - last - - - -

    -

    -
    -
    -

    Returns the last element of the array.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - diff --git a/docs/boolean.html b/docs/boolean.html index dad89d8..0e377d8 100755 --- a/docs/boolean.html +++ b/docs/boolean.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -106,7 +106,8 @@

    Boolean

    Description


    BooleanObject represents boolean object in goby. - It includes true and FALSE which represents logically true and false value.

    + It includes true and FALSE which represents logically true and false value. + - Boolean.new is not supported.

    Class Methods

    @@ -119,144 +120,6 @@

    Class Methods

    Instance Methods


    -

    - # -

    - == - - - -

    -

    -
    -
    -

    Returns true if the receiver equals to the argument.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - != - - - -

    -

    -
    -
    -

    Returns true if the receiver is not equals to the argument.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - ! - - - -

    -

    -
    -
    -

    Reverse the receiver.

    - -
     !true  # => false
    - !false # => true
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - && - - - -

    -

    -
    -
    -

    Returns true if both the receiver and the argument are true.

    - -
     3 > 2 && 5 > 3  # => true
    - 3 > 2 && 5 > 10 # => false
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - || - - - -

    -

    -
    -
    -

    Returns true either if the receiver or argument is true.

    - -
     3 > 2 || 5 > 3  # => true
    - 3 > 2 || 5 > 10 # => true
    - 2 > 3 || 5 > 10 # => false
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - diff --git a/docs/base_object.html b/docs/channel.html similarity index 89% rename from docs/base_object.html rename to docs/channel.html index 0fceadb..d22cf70 100755 --- a/docs/base_object.html +++ b/docs/channel.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -101,11 +101,11 @@
    -

    BaseObject

    +

    Channel

    Description


    -

    BaseObject is an interface that implements basic functions any object requires.

    +

    ChannelObject represents a goby channel, which carries a golang channel

    Class Methods

    diff --git a/docs/class.html b/docs/class.html deleted file mode 100755 index f7e81e4..0000000 --- a/docs/class.html +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - Goby API Documentation - - - -
    - - - - -
    -

    Class

    - -

    Description

    -
    -

    Class is an interface that implements a class’s basic functions.

    - -
      -
    • lookupClassMethod: search for current class’s class method with given name.
    • -
    • lookupInstanceMethod: search for current class’s instance method with given name.
    • -
    • ReturnName returns class’s name
    • -
    -
    - -

    Class Methods

    -
    - -

    - # -

    - attr_reader - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - attr_writer - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - attr_accessor - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - include - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - new - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - name - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - superclass - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - - - - - -

    Instance Methods

    -
    - -
    - -
    - - diff --git a/docs/error.html b/docs/error.html index 2620ec5..0f5f162 100755 --- a/docs/error.html +++ b/docs/error.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,22 @@

    Error

    Description


    -
    +

    Error class is actually a special struct to hold internal error types with messages. + Goby developers need not to take care of the struct. + Goby maintainers should consider using the appropriate error type. + Cannot create instances of Error class, or inherit Error class.

    + +

    The type of internal errors:

    + +
      +
    • InternalError: default error type
    • +
    • ArgumentError: an argument-related error
    • +
    • NameError: a constant-related error
    • +
    • TypeError: a type-related error
    • +
    • UndefinedMethodError: undefined-method error
    • +
    • UnsupportedMethodError: intentionally unsupported-method error
    • +
    +

    Class Methods


    diff --git a/docs/file.html b/docs/file.html index fd7e328..f0caa65 100755 --- a/docs/file.html +++ b/docs/file.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,420 +105,12 @@

    File

    Description


    -
    +

    FileObject is a special type that contains file pointer so we can keep track on target file.

    +

    Class Methods


    -

    - # -

    - extname - - ( - - - filename - - - ) - - - => - - - - - String - - - -

    -

    -
    -
    -

    Returns extension part of a File

    - -
     File.extname("loop.gb") # => .gb
    -
    - -
    -
    - - -
      -
    • - Parameter: filename - - - (String) - - : - - - No Doc - -
    • -
    - - - - -
      -
    • - Return: (String) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - chmod - - ( - - - filename - - - ) - - - => - - - - - Integer - - - -

    -

    -
    -
    -

    Changes the mode of the file. - Return number of files.

    - -
     File.chmod(0755, "test.sh") # => 1
    - File.chmod(0755, "goby", "../test.sh") # => 2
    -
    - -
    -
    - - -
      -
    • - Parameter: filename - - - (String) - - : - - - No Doc - -
    • -
    - - - - -
      -
    • - Return: (Integer) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - size - - ( - - - filename - - - ) - - - => - - - - - Integer - - - -

    -

    -
    -
    -

    Returns size of file in bytes.

    - -
     File.size("loop.gb") # => 321123
    -
    - -
    -
    - - -
      -
    • - Parameter: filename - - - (String) - - : - - - No Doc - -
    • -
    - - - - -
      -
    • - Return: (Integer) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - basename - - ( - - - filepath - - - ) - - - => - - - - - String - - - -

    -

    -
    -
    -

    Returns the last element from path.

    - -
     File.basename("/home/goby/plugin/loop.gb") # => loop.gb
    -
    - -
    -
    - - -
      -
    • - Parameter: filepath - - - (String) - - : - - - No Doc - -
    • -
    - - - - -
      -
    • - Return: (String) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - join - - - => - - - - - String - - - -

    -

    -
    -
    -

    Returns string with joined elements.

    - -
     File.join("home", "goby", "plugin") # => home/goby/plugin
    -
    - -
    -
    - - - -
      -
    • - Return: (String) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - split - - ( - - - filepath - - - ) - - - => - - - - - Array - - - -

    -

    -
    -
    -

    Returns array of path and file.

    - -
     File.split("/home/goby/.settings") # => ["/home/goby/", ".settings"]
    -
    - -
    -
    - - -
      -
    • - Parameter: filepath - - - (String) - - : - - - No Doc - -
    • -
    - - - - -
      -
    • - Return: (Array) : - - No Doc - -
    • -
    - - -
    -
    -

    - ( - source - ) -

    - diff --git a/docs/hash.html b/docs/hash.html index 0fb8889..397216f 100755 --- a/docs/hash.html +++ b/docs/hash.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,37 @@

    Hash

    Description


    -

    HashObject represents hash instances

    +

    HashObject represents hash instances + Hash is a collection of key-value pair, which works like a dictionary. + Hash literal is represented with curly brackets { } like { key: value }. + Each key of the hash is unique and cannot be duplicate within the hash. + Adding a leading space and a trailing space within curly brackets are preferable.

    + +
      +
    • Key: an alphanumeric word that starts with alphabet, without containing space and punctuations. +Underscore _ can also be used within the key. +String literal like “mickey mouse” cannot be used as a hash key. +The internal key is actually a String and not a Symbol for now (TBD). +Thus only a String object or a string literal should be used when referencing with [ ].
    • +
    + +
     a = { balthazar1: 100 } # valid
    + b = { 2melchior: 200 }  # invalid
    + x = 'balthazar1'
    +
    + a["balthazar1"]  # => 100
    + a[x]             # => 100
    + a[balthazar1]    # => error
    +
    + + + +

    Note: + - The order of key-value pairs are not preserved. + - Operator => is not supported. + - Hash.new is not supported.

    Class Methods

    @@ -118,78 +148,6 @@

    Class Methods

    Instance Methods


    -

    - # -

    - [] - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - []= - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - length - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    -
    diff --git a/docs/index.html b/docs/index.html index 52f5637..40e42d3 100755 --- a/docs/index.html +++ b/docs/index.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String diff --git a/docs/integer.html b/docs/integer.html index 1dde45b..7585fe1 100755 --- a/docs/integer.html +++ b/docs/integer.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -110,6 +110,10 @@

    Description

     1 + 1 # => 2
      2 * 2 # => 4
     
    + +
      +
    • Integer.new is not supported.
    • +

    Class Methods

    @@ -122,560 +126,6 @@

    Class Methods

    Instance Methods


    -

    - # -

    - + - - ( - - - other - - - ) - - - -

    -

    -
    -
    -

    Returns the sum of self and another Integer

    - -
    -
    - - -
      -
    • - Parameter: other - - - (Integer) - - : - - - No Doc - -
    • -
    - - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - - - - - -

    -

    -
    -
    -

    Returns the subtraction of another Integer from self.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - * - - - -

    -

    -
    -
    -

    Returns self multiplying another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - ** - - - -

    -

    -
    -
    -

    Returns self squaring another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - / - - - -

    -

    -
    -
    -

    Returns self divided by another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - > - - - -

    -

    -
    -
    -

    Returns if self is larger than another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - >= - - - -

    -

    -
    -
    -

    Returns if self is larger than or equals to another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - < - - - -

    -

    -
    -
    -

    Returns if self is smaller than another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - <= - - - -

    -

    -
    -
    -

    Returns if self is smaller than or equals to another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - <=> - - - -

    -

    -
    -
    -

    Returns 1 if self is larger than the incoming Integer -1 if smaller. Otherwise 0.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - == - - - -

    -

    -
    -
    -

    Returns if self is equal to another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - != - - - -

    -

    -
    -
    -

    Returns if self is not equal to another Integer

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - ++ - - - -

    -

    -
    -
    -

    Adds 1 to self and returns.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - -- - - - -

    -

    -
    -
    -

    Substracts 1 from self and returns.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - to_s - - - -

    -

    -
    -
    -

    Returns a String representation of self.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - to_i - - - -

    -

    -
    -
    -

    Returns self.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - even - - - -

    -

    -
    -
    -

    Returns if self is even.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - odd - - - -

    -

    -
    -
    -

    Returns if self is odd.

    - -
     3.odd # => true
    - 4.odd # => false
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - next - - - -

    -

    -
    -
    -

    Returns self + 1.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - pred - - - -

    -

    -
    -
    -

    Returns self - 1.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - times - - - -

    -

    -
    -
    -

    Yields a block a number of times equals to self.

    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - diff --git a/docs/method.html b/docs/method.html index 8bb3391..afe1050 100755 --- a/docs/method.html +++ b/docs/method.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,7 @@

    Method

    Description


    -

    Method represents methods defined using goby.

    +

    BuiltInMethodObject represents methods defined in go.

    Class Methods

    diff --git a/docs/null.html b/docs/null.html index f39af90..6650bb1 100755 --- a/docs/null.html +++ b/docs/null.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,9 @@

    Null

    Description


    -

    NullObject represnts the null value in Goby.

    +

    NullObject (nil) represents the null value in Goby. + nil is convert into null when exported to JSON format. + - Null.new is not supported.

    Class Methods

    diff --git a/docs/object.html b/docs/object.html index f19886d..22f5aed 100755 --- a/docs/object.html +++ b/docs/object.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,8 @@

    Object

    Description


    -
    +

    RObject represents any non built-in class’s instance.

    +

    Class Methods


    diff --git a/docs/range.html b/docs/range.html new file mode 100755 index 0000000..74adb15 --- /dev/null +++ b/docs/range.html @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Range

    + +

    Description

    +
    +

    RangeObject is the built in range class + Range represents an interval: a set of values from the beginning to the end specified. + Currently, only Integer objects or integer literal are supported.

    + +
     r = 0
    + (1..(1+4)).each do |i|
    +   puts(r = r + i)
    + end
    +
    + +
     r = 0
    + a = 1
    + b = 5
    + (a..b).each do |i|
    +   r = r + i
    + end
    +
    +
    + +

    Class Methods

    +
    + + + + + +

    Instance Methods

    +
    + +
    + +
    + + diff --git a/docs/string.html b/docs/string.html index ffc57c9..86d632c 100755 --- a/docs/string.html +++ b/docs/string.html @@ -30,21 +30,15 @@
  • - -
  • - BaseObject -
  • -
    -
  • Boolean
  • - +
  • - Class + Channel
  • @@ -90,6 +84,12 @@ + +
  • + Range +
  • +
    +
  • String @@ -105,7 +105,25 @@

    String

    Description


    -

    StringObject represents string instances

    +

    StringObject represents string instances + String object holds and manipulates a sequence of characters. + String objects may be created using as string literals. + Double or single quotations can be used for representation.

    + +
     a = "Three"
    + b = 'zero'
    + c = 'ζΌ’'
    + d = 'TiαΊΏng Việt'
    + e = "😏️️"
    +
    + +

    Note:

    + +
      +
    • Currently, manipulations are based upon Golang’s Unicode manipulations.
    • +
    • Currently, UTF-8 encoding is assumed based upon Golang’s string manipulation, but the encoding is not actually specified(TBD).
    • +
    • String.new is not supported.
    • +

    Class Methods

    @@ -118,366 +136,6 @@

    Class Methods

    Instance Methods


    -

    - # -

    - + - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - * - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - > - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - < - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - == - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - <=> - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - != - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - capitalize - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - upcase - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - downcase - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - size - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - length - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - reverse - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - to_s - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    - -

    - # -

    - to_i - - - -

    -

    -
    -
    - -
    -
    - - -
    -
    -

    - ( - source - ) -

    -
    diff --git a/parser.go b/parser.go index c63b1b0..bbeb421 100644 --- a/parser.go +++ b/parser.go @@ -9,6 +9,8 @@ import ( "html/template" "io/ioutil" "strings" + + "github.com/k0kubun/pp" ) func ClassesFromDir(dir string) []Class { @@ -62,19 +64,22 @@ func classFromFile(filepath string) Class { node := tSpec.Name class.Line = fset.Position(node.NamePos).Line } + } + } - // Assign class methods if found - vSpec, ok := spec.(*ast.ValueSpec) - if ok { - if class.MatchClassMethods(vSpec.Names[0].Name) { - classMethods = vSpec - } - - // Assign instance methods if found - if class.MatchInstanceMethods(vSpec.Names[0].Name) { - instanceMethods = vSpec - } - } + // Continue only for func declarations + if funcDecl, ok := decl.(*ast.FuncDecl); ok { + decl := funcDecl.Name.Name + // Assign instance methods if found + if class.MatchInstanceMethods(decl) { + //instanceMethods = funcDecl + pp.Println("MatchInstanceMethods: ", decl) + } + + // Assign class methods if found + if class.MatchClassMethods(decl) { + pp.Println("MatchClassMethods: ", decl) + //classMethods = funcDecl } } } diff --git a/settings.yml b/settings.yml index c759eb0..f3f32d0 100644 --- a/settings.yml +++ b/settings.yml @@ -18,4 +18,4 @@ gobypath: "/src/github.com/goby-lang/goby" # # The source always refers to a specific commit, so don't put in branch name like 'master' or 'development'. repo: "https://github.com/goby-lang/goby" -commit: "64069b9916f61d76ee828d3983c5269e0dd037b3" +commit: "a439b3a9fb4194c4ebe5388468d68cc755fa3b02" From 7ddc1ee85d5a9d2d0ca3e82e4e1965cb25c40a3c Mon Sep 17 00:00:00 2001 From: hachi8833 Date: Sat, 22 Jul 2017 12:06:07 +0900 Subject: [PATCH 3/3] Update retrieveMethodsFromNode Update commit id Update for loops in retrieveMethodsFromNode() Fix variable names Extract FnName and FnLine Parse comments, params, returns Remove redundant for loop Remove redundant for loop Remove redundant for loop --- docs/array.html | 571 ++++++++++++++ docs/boolean.html | 271 +++++++ docs/channel.html | 126 ++++ docs/class.html | 1774 ++++++++++++++++++++++++++++++++++++++++++++ docs/error.html | 30 + docs/file.html | 702 ++++++++++++++++++ docs/hash.html | 980 ++++++++++++++++++++++++ docs/http.html | 179 +++++ docs/index.html | 30 + docs/integer.html | 1107 ++++++++++++++++++++++++++++ docs/method.html | 30 + docs/null.html | 30 + docs/object.html | 30 + docs/plugin.html | 179 +++++ docs/range.html | 30 + docs/string.html | 1799 +++++++++++++++++++++++++++++++++++++++++++++ docs/struct.html | 179 +++++ docs/uri.html | 186 +++++ parser.go | 39 +- settings.yml | 4 +- 20 files changed, 8257 insertions(+), 19 deletions(-) create mode 100755 docs/class.html create mode 100755 docs/http.html create mode 100755 docs/plugin.html create mode 100755 docs/struct.html create mode 100755 docs/uri.html diff --git a/docs/array.html b/docs/array.html index 647b4eb..6f81297 100755 --- a/docs/array.html +++ b/docs/array.html @@ -42,6 +42,12 @@
  • + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -120,6 +150,547 @@

    Class Methods

    Instance Methods


    +

    + # +

    + [] + + + +

    +

    +
    +
    +

    Retrieves an object in an array using Integer index. + The index starts from 0. It returns null if the given index is bigger than its size.

    + +
     a = [1, 2, 3, "a", "b", "c"]
    + a[0]  # => 1
    + a[3]  # => "a"
    + a[10] # => nil
    + a[-1] # => "c"
    + a[-3] # => "a"
    + a[-7] # => nil
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + []= + + + +

    +

    +
    +
    +

    Assigns value to an array. It requires an index and a value as argument. + The array will expand if the assigned index is bigger than its size. + Returns the assigned value.

    + +
     a = []
    + a[0] = 10  # => 10
    + a[3] = 20  # => 20
    + a          # => [10, nil, nil, 20]
    + a[-2] = 5  # => [10, nil, 5, 20]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + at + + + +

    +

    +
    +
    +

    Retrieves an object in an array using the index argument. + It raises an error if index out of range.

    + +
     a = [1, 2, 3]
    + a.at(0)  # => 1
    + a.at(10) # => nil
    + a.at(-2) # => 2
    + a.at(-4) # => nil
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + clear + + + +

    +

    +
    +
    +

    Removes all elements in the array and returns an empty array.

    + +
     a = [1, 2, 3]
    + a.clear # => []
    + a       # => []
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + concat + + + +

    +

    +
    +
    +

    Appends any number of argument to the array.

    + +
     a = [1, 2, 3]
    + a.concat(4, 5, 6)
    + a # => [1, 2, 3, 4, 5, 6]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + count + + + +

    +

    +
    +
    +

    Loop through each element with the given block. + Return the sum of elements that return true from yield.

    + +
     a = [1, 2, 3, 4, 5]
    +
    + a.count do |e|
    +   e * 2 > 3
    + end
    + # => 4
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + each + + + +

    +

    +
    +
    +

    Loop through each element with the given block.

    + +
     a = ["a", "b", "c"]
    +
    + a.each do |e|
    +   puts(e + e)
    + end
    + # => "aa"
    + # => "bb"
    + # => "cc"
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + each_index + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + first + + + +

    +

    +
    +
    +

    Returns the first element of the array.

    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + last + + + +

    +

    +
    +
    +

    Returns the last element of the array.

    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + length + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the length of the array.

    + +
     [1, 2, 3].length # => 3
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + map + + + +

    +

    +
    +
    +

    Loop through each element with the given block. Return a new array with each yield element.

    + +
     a = ["a", "b", "c"]
    +
    + a.map do |e|
    +   e + e
    + end
    + # => ["aa", "bb", "cc"]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + pop + + + +

    +

    +
    +
    +

    Removes the last element in the array and returns it.

    + +
     a = [1, 2, 3]
    + a.pop # => 3
    + a     # => [1, 2]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + push + + + +

    +

    +
    +
    +

    Appends the given object to the array and returns the array.

    + +
     a = [1, 2, 3]
    + a.push(4) # => [1, 2, 3, 4]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + rotate + + + +

    +

    +
    +
    +

    Returns a new array by putting the desired element as the first element. + Use integer index as an argument to retrieve the element.

    + +
     a = ["a", "b", "c", "d"]
    +
    + a.rotate    # => ["b", "c", "d", "a"]
    + a.rotate(2) # => ["c", "d", "a", "b"]
    + a.rotate(3) # => ["d", "a", "b", "c"]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + select + + + +

    +

    +
    +
    +

    Loop through each element with the given block. + Return a new array with each element that returns true from yield.

    + +
     a = [1, 2, 3, 4, 5]
    +
    + a.select do |e|
    +   e + 1 > 3
    + end
    + # => [3, 4, 5]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + shift + + + +

    +

    +
    +
    +

    Removes the first element in the array and returns it.

    + +
     a = [1, 2, 3]
    + a.shift # => 1
    + a       # => [2, 3]
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/boolean.html b/docs/boolean.html index 0e377d8..22fcf9a 100755 --- a/docs/boolean.html +++ b/docs/boolean.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -120,6 +150,247 @@

    Class Methods

    Instance Methods


    +

    + # +

    + == + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if the receiver equals to the argument.

    + +
     1 == 1 # => true
    + 100 == 33 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + != + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if the receiver is not equals to the argument.

    + +
     4 != 2 # => true
    + 45 != 45 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + ! + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Reverse the receiver.

    + +
     !true  # => false
    + !false # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + && + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if both the receiver and the argument are true.

    + +
     3 > 2 && 5 > 3  # => true
    + 3 > 2 && 5 > 10 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + || + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true either if the receiver or argument is true.

    + +
     3 > 2 || 5 > 3  # => true
    + 3 > 2 || 5 > 10 # => true
    + 2 > 3 || 5 > 10 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/channel.html b/docs/channel.html index d22cf70..137da99 100755 --- a/docs/channel.html +++ b/docs/channel.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -111,6 +141,30 @@

    Description

    Class Methods


    +

    + # +

    + new + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + @@ -118,6 +172,78 @@

    Class Methods

    Instance Methods


    +

    + # +

    + close + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + deliver + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + receive + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/class.html b/docs/class.html new file mode 100755 index 0000000..142cc60 --- /dev/null +++ b/docs/class.html @@ -0,0 +1,1774 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Class

    + +

    Description

    +
    +
    + +

    Class Methods

    +
    + +

    + # +

    + attr_accessor + + ( + + + *args + + + ) + + + => + + + + + Null + + + +

    +

    +
    +
    +

    Creates instance variables and corresponding methods that return the value of + each instance variable and assign an argument to each instance variable. + Only string literal can be used for now.

    + +
     class Foo
    +   attr_accessor("bar", "buz")
    + end
    +
    + +

    is equivalent to:

    + +
     class Foo
    +   def bar
    +     @bar
    +   end
    +   def buz
    +     @buz
    +   end
    +   def bar=(val)
    +     @bar = val
    +   end
    +   def buz=(val)
    +     @buz = val
    +   end
    + end
    +
    + +
    +
    + + +
      +
    • + Parameter: *args + + + (String) + + : + + + One or more quoted method names for ‘getter/setter’ + +
    • +
    + + + + +
      +
    • + Return: (Null) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + attr_reader + + ( + + + *args + + + ) + + + => + + + + + Null + + + +

    +

    +
    +
    +

    Creates instance variables and corresponding methods that return the value of each + instance variable.

    + +

    Only string literal can be used for now.

    + +
     class Foo
    +   attr_reader("bar", "buz")
    + end
    +
    + +

    is equivalent to:

    + +
     class Foo
    +   def bar
    +     @bar
    +   end
    +   def buz
    +     @buz
    +   end
    + end
    +
    + +
    +
    + + +
      +
    • + Parameter: *args + + + (String) + + : + + + One or more quoted method names for ‘getter’ + +
    • +
    + + + + +
      +
    • + Return: (Null) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + attr_writer + + ( + + + *args + + + ) + + + => + + + + + Null + + + +

    +

    +
    +
    +

    Creates instance variables and corresponding methods that assign an argument to each + instance variable. No return value.

    + +

    Only string literal can be used for now.

    + +
     class Foo
    +   attr_writer("bar", "buz")
    + end
    +
    + +

    is equivalent to:

    + +
     class Foo
    +   def bar=(val)
    +     @bar = val
    +   end
    +   def buz=(val)
    +     @buz = val
    +   end
    + end
    +
    + +
    +
    + + +
      +
    • + Parameter: *args + + + (String) + + : + + + One or more quoted method names for ‘setter’ + +
    • +
    + + + + +
      +
    • + Return: (Null) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + include + + ( + + + module + + + ) + + + => + + + + + Null + + + +

    +

    +
    +
    +

    Includes a module for mixin, which inherits only methods and constants from the module. + The included module is inserted into the path of the inheritance tree, between the class + and the superclass so that the methods of the module is prioritized to superclasses.

    + +

    The order of include affects: the modules that included later are prioritized. + If multiple modules include the same methods, the method will only come from + the last included module.

    + +
     module Foo
    + def ten
    +    10
    + end
    + end
    +
    + module Bar
    +   def ten
    +     "ten"
    +   end
    + end
    +
    + class Baz
    +   include(Foo)
    +   include(Bar) # method `ten` is only included from this module
    + end
    +
    + a = Baz.new
    + puts(a.ten) # => ten (overriden)
    +
    + +

    Note:

    + +

    You cannot use string literal, or pass two or more arguments to include.

    + +
       include("Foo")    # => error
    +   include(Foo, Bar) # => error
    +
    + +

    Including modules into built-in classes such as String are not supported:

    + +
     module Foo
    +   def ten
    +     10
    +   end
    + end
    + class String
    +   include(Foo) # => error
    + end
    +
    + +
    +
    + + +
      +
    • + Parameter: module + + + (Class) + + : + + + Module name to include + +
    • +
    + + + + +
      +
    • + Return: (Null) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + name + + ( + + + class + + + ) + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns the name of the class (receiver).

    + +
     puts(Array.name)  # => Array
    + puts(Class.name)  # => Class
    + puts(Object.name) # => Object
    +
    + +
    +
    + + +
      +
    • + Parameter: class + + + (Class) + + : + + + Receiver + +
    • +
    + + + + +
      +
    • + Return: (String) : + + receiver name
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + new + + ( + + + class + + + ) + + + => + + + + + Object + + + +

    +

    +
    +
    +

    Creates and returns a new anonymous class from a receiver. + You can use any classes you defined as the receiver:

    + +
     class Foo
    + end
    + a = Foo.new
    +
    + +

    Note that the built-in classes such as Class or String are not open for creating instances + and you can’t call new against them.

    + +
     a = Class.new  # => error
    + a = String.new # => error
    +
    + +
    +
    + + +
      +
    • + Parameter: class + + + (Class) + + : + + + Receiver + +
    • +
    + + + + +
      +
    • + Return: (Object) : + + object
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + superclass + + ( + + + class + + + ) + + + => + + + + + Object + + + +

    +

    +
    +
    +

    Returns the superclass object of the receiver.

    + +
     puts(Array.superclass)  # => <Class:Object>
    + puts(String.superclass) # => <Class:Object>
    +
    + class Foo;end
    + class Bar < Foo
    + end
    + puts(Foo.superclass)    # => <Class:Object>
    + puts(Bar.superclass)    # => <Class:Foo>
    +
    + +

    Note: the following is not supported:

    + +
      +
    • Class class

    • + +
    • Object class

    • + +
    • instance objects or object literals

    • +
    + +
     puts("string".superclass) # => error
    + puts(Class.superclass)    # => error
    + puts(Object.superclass)   # => error
    +
    + +
    +
    + + +
      +
    • + Parameter: class + + + (Class) + + : + + + Receiver + +
    • +
    + + + + +
      +
    • + Return: (Object) : + + object of the receiver
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + + + + + +

    Instance Methods

    +
    + +

    + # +

    + == + + + => + + + + + @boolean + + + +

    +

    +
    +
    +

    General method for comparing equalty of the objects

    + +
     123 == 123   # => true
    + 123 == "123" # => false
    +
    + # Hash will not concern about the key-value pair order
    + { a: 1, b: 2 } == { a: 1, b: 2 } # => true
    + { a: 1, b: 2 } == { b: 2, a: 1 } # => true
    +
    + # Hash key will be override if the key duplicated
    + { a: 1, b: 2 } == { a: 2, b: 2, a: 1 } # => true
    + { a: 1, b: 2 } == { a: 1, b: 2, a: 2 } # => false
    +
    + # Array will concern about the order of the elements
    + [1, 2, 3] == [1, 2, 3] # => true
    + [1, 2, 3] == [3, 2, 1] # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (@boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + != + + + => + + + + + @boolean + + + +

    +

    +
    +
    +

    General method for comparing inequalty of the objects

    + +
     123 != 123   # => false
    + 123 != "123" # => true
    +
    + # Hash will not concern about the key-value pair order
    + { a: 1, b: 2 } != { a: 1, b: 2 } # => false
    + { a: 1, b: 2 } != { b: 2, a: 1 } # => false
    +
    + # Hash key will be override if the key duplicated
    + { a: 1, b: 2 } != { a: 2, b: 2, a: 1 } # => false
    + { a: 1, b: 2 } != { a: 1, b: 2, a: 2 } # => true
    +
    + # Array will concern about the order of the elements
    + [1, 2, 3] != [1, 2, 3] # => false
    + [1, 2, 3] != [3, 2, 1] # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (@boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + import + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + require + + ( + + + filename + + + ) + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Loads the given Goby library name without extension (mainly for modules), returning true + if successful and false if the feature is already loaded.

    + +

    Currently, only the following embedded Goby libraries are targeted:

    + +
      +
    • “file”
    • +
    • “net/http”
    • +
    • “net/simple_server”
    • +
    • “uri”
    • +
    + +
     require("file")
    + File.extname("foo.rb")
    +
    + +

    TBD: the load paths for require

    + +
    +
    + + +
      +
    • + Parameter: filename + + + (String) + + : + + + Quoted file name of the library, without extension + +
    • +
    + + + + +
      +
    • + Return: (Boolean) : + + of loading module
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + require_relative + + ( + + + path/name + + + ) + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Loads the Goby library (mainly for modules) from the given local path plus name + without extension from the current directory, returning true if successful, + and false if the feature is already loaded.

    + +
     require_relative("../test_fixtures/require_test/foo")
    + fifty = Foo.bar(5)
    +
    + +
    +
    + + +
      +
    • + Parameter: path/name + + + (String) + + : + + + Quoted file path to library plus name, without extension + +
    • +
    + + + + +
      +
    • + Return: (Boolean) : + + of loading module
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + puts + + ( + + + *args + + + ) + + + => + + + + + Null + + + +

    +

    +
    +
    +

    Puts string literals or objects into stdout with a tailing line feed, converting into String if needed.

    + +
     puts("foo", "bar")
    + # => foo
    + # => bar
    + puts("baz", String.name)
    + # => baz
    + # => String
    + puts("foo" + "bar")
    + # => foobar
    +
    + +

    TODO: interpolation is needed to be implemented.

    + +
    +
    + + +
      +
    • + Parameter: *args + + + (Class) + + : + + + String literals, or other objects that can be converted into String . + +
    • +
    + + + + +
      +
    • + Return: (Null) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + class + + ( + + + object + + + ) + + + => + + + + + Class + + + +

    +

    +
    +
    +

    Returns the class of the object. Receiver cannot be omitted.

    + +

    FYI: You can convert the class into String with #name.

    + +
     puts(100.class)         # => <Class:Integer>
    + puts(100.class.name)    # => Integer
    + puts("123".class)       # => <Class:String>
    + puts("123".class.name)  # => String
    +
    + +
    +
    + + +
      +
    • + Parameter: object + + + (Object) + + : + + + Receiver (required) + +
    • +
    + + + + +
      +
    • + Return: (Class) : + + class of the receiver
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + ! + + ( + + + object + + + ) + + + => + + + + + Object + + + +

    +

    +
    +
    +

    Inverts the boolean value.

    + +
     !true  # => false
    + !false # => true
    +
    + +
    +
    + + +
      +
    • + Parameter: object + + + (Object) + + : + + + object that return boolean value to invert + +
    • +
    + + + + +
      +
    • + Return: (Object) : + + boolean value
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + sleep + + ( + + + sec + + + ) + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Suspends the current thread for duration (sec).

    + +

    Note: currently, parameter cannot be omitted, and only Integer can be specified.

    + +
     a = sleep(2)
    + puts(a)     # => 2
    +
    + +
    +
    + + +
      +
    • + Parameter: sec + + + (Integer) + + : + + + time to wait in sec + +
    • +
    + + + + +
      +
    • + Return: (Integer) : + + time slept in sec
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_s + + ( + + + n/a + + + ) + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns object’s string representation.

    + +
    +
    + + +
      +
    • + Parameter: n/a + + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (String) : + + string representation.
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + block_given + + ( + + + n/a + + + ) + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if a block is given in the current context and yield is ready to call.

    + +

    Note: The method name does not end with ‘?’ because the sign is unavalable in Goby for now.

    + +
     class File
    +   def self.open(filename, mode, perm)
    +     file = new(filename, mode, perm)
    +
    +     if block_given
    +       yield(file)
    +     end
    +
    +     file.close
    +   end
    + end
    +
    + +
    +
    + + +
      +
    • + Parameter: n/a + + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + thread + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + is_a + + ( + + + n/a + + + ) + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if Object class is equal to the input argument class

    + +
     "Hello".is_a(String)            # => true
    + 123.is_a(Integer)               # => true
    + [1, true, "String"].is_a(Array) # => true
    + { a: 1, b: 2 }.is_a(Hash)       # => true
    + "Hello".is_a(Integer)           # => false
    + 123.is_a(Range)                 # => false
    + (2..4).is_a(Hash)               # => false
    + nil.is_a(Integer)               # => false
    +
    + +
    +
    + + +
      +
    • + Parameter: n/a + + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + is_nil + + ( + + + n/a + + + ) + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if Object is nil

    + +
     123.is_nil            # => false
    + "String".is_nil       # => false
    + { a: 1, b: 2 }.is_nil # => false
    + (3..5).is_nil         # => false
    + nil.is_nil            # => true  (See the implementation of Null#is_nil in vm/null.go file)
    +
    + +
    +
    + + +
      +
    • + Parameter: n/a + + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + instance_variable_get + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + instance_variable_set + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +
    + +
    + + diff --git a/docs/error.html b/docs/error.html index 0f5f162..ff4fc52 100755 --- a/docs/error.html +++ b/docs/error.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/file.html b/docs/file.html index f0caa65..453a1d7 100755 --- a/docs/file.html +++ b/docs/file.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -111,6 +141,535 @@

    Description

    Class Methods


    +

    + # +

    + basename + + ( + + + filepath + + + ) + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns the last element from path.

    + +
     File.basename("/home/goby/plugin/loop.gb") # => loop.gb
    +
    + +
    +
    + + +
      +
    • + Parameter: filepath + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + chmod + + ( + + + filename + + + ) + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Changes the mode of the file. + Return number of files.

    + +
     File.chmod(0755, "test.sh") # => 1
    + File.chmod(0755, "goby", "../test.sh") # => 2
    +
    + +
    +
    + + +
      +
    • + Parameter: filename + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + delete + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + exist + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + extname + + ( + + + filename + + + ) + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns extension part of file.

    + +
     File.extname("loop.gb") # => .gb
    +
    + +
    +
    + + +
      +
    • + Parameter: filename + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + join + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns string with joined elements.

    + +
     File.join("home", "goby", "plugin") # => home/goby/plugin
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + new + + ( + + + filename + + + ) + + + => + + + + + File + + + +

    +

    +
    +
    +

    Finds the file with given filename and initializes a file object with it.

    + +
     File.new("./samples/server.gb")
    +
    + +
    +
    + + +
      +
    • + Parameter: filename + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (File) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + size + + ( + + + filename + + + ) + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns size of file in bytes.

    + +
     File.size("loop.gb") # => 321123
    +
    + +
    +
    + + +
      +
    • + Parameter: filename + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + split + + ( + + + filepath + + + ) + + + => + + + + + Array + + + +

    +

    +
    +
    +

    Returns array of path and file.

    + +
     File.split("/home/goby/.settings") # => ["/home/goby/", ".settings"]
    +
    + +
    +
    + + +
      +
    • + Parameter: filepath + + + (String) + + : + + + No Doc + +
    • +
    + + + + +
      +
    • + Return: (Array) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + @@ -118,6 +677,149 @@

    Class Methods

    Instance Methods


    +

    + # +

    + close + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + name + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + read + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + size + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns size of file in bytes.

    + +
     File.new("loop.gb").size # => 321123
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + write + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/hash.html b/docs/hash.html index 397216f..1e392dd 100755 --- a/docs/hash.html +++ b/docs/hash.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -148,6 +178,956 @@

    Class Methods

    Instance Methods


    +

    + # +

    + [] + + + => + + + + + Object + + + +

    +

    +
    +
    +

    Retrieves the value (object) that corresponds to the key specified. + Returns nil when specifying a nonexistent key.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: 'v' } }
    + h['a'] #=> 1
    + h['b'] #=> "2"
    + h['c'] #=> [1, 2, 3]
    + h['d'] #=> { k: 'v' }
    +
    + +
    +
    + + + +
      +
    • + Return: (Object) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + []= + + + => + + + + + Object + + + +

    +

    +
    +
    +

    Associates the value given by value with the key given by key. + Returns the value.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: 'v' } }
    + h['a'] = 1          #=> 1
    + h['b'] = "2"        #=> "2"
    + h['c'] = [1, 2, 3]  #=> [1, 2, 3]
    + h['d'] = { k: 'v' } #=> { k: 'v' }
    +
    + +
    +
    + + + +
      +
    • + Return: (Object) : + + value
    • + + +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + clear + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns empty hash (no key-value pairs)

    + +
     { a: "Hello", b: "World" }.clear # => {}
    + {}.clear                         # => {}
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + each_key + + + => + + + + + Array + + + +

    +

    +
    +
    +

    Loop through keys of the hash with given block frame. It also returns array of + keys in alphabetical order.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: 'v' } }
    + h.each_key do |k|
    +   puts k
    + end
    + # => a
    + # => b
    + # => c
    + # => d
    +
    + +
    +
    + + + +
      +
    • + Return: (Array) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + each_value + + + +

    +

    +
    +
    +

    Loop through values of the hash with given block frame. It also returns array of + values of the hash in the alphabetical order of its key

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: "v" } }
    + h.each_value do |v|
    +   puts v
    + end
    + # => 1
    + # => "2"
    + # => [1, 2, 3]
    + # => { k: "v" }
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + empty + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if hash has no key-value pairs

    + +
     {}.empty       # => true
    + { a: 1 }.empty # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + eql + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if hash is exactly equal to another hash

    + +
     { a: "Hello", b: "World" }.eql(1) # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + has_key + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if the key exist in the hash. Currently, it can only input string + type object.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: "v" } }
    + h.has_key("a") # => true
    + h.has_key("e") # => false
    + # TODO: Support Symbol Type Key Input
    + h.has_key(:b)  # => true
    + h.has_key(:f)  # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + has_value + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if the value exist in the hash.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: "v" } }
    + h.has_value(1)          # => true
    + h.has_value(2)          # => false
    + h.has_value("2")        # => true
    + h.has_value([1, 2, 3])  # => true
    + h.has_value({ k: "v" }) # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + keys + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns an array of keys (in arbitrary order)

    + +
     { a: 1, b: "2", c: [3, true, "Hello"] }.keys
    + # =>  ["c", "b", "a"] or ["b", "a", "c"] ... etc
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + length + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the number of key-value pairs of the hash.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3], d: { k: 'v' } }
    + h.length  #=> 4
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + map_values + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a new hash with the results of running the block once for every value. + This method does not change the keys and the receiver hash values.

    + +
     h = { a: 1, b: 2, c: 3 }
    + result = h.transform_values do |v|
    +   v * 3
    + end
    + h      # => { a: 3, b: 6, c: 9 }
    + result # => { a: 3, b: 6, c: 9 }
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + merge + + + => + + + + + Hash + + + +

    +

    +
    +
    +

    Returns the number of key-value pairs of the hash.

    + +
     h = { a: 1, b: "2", c: [1, 2, 3] }
    + h.merge({ b: "Hello", d: "World" })
    + # => { a: 1, b: "Hello", c: [1, 2, 3], d: "World" }
    +
    + +
    +
    + + + +
      +
    • + Return: (Hash) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + sorted_keys + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns an array of keys (in arbitrary order)

    + +
     { a: 1, b: "2", c: [3, true, "Hello"] }.sorted_keys
    + # =>  ["a", "b", "c"]
    + { c: 1, b: "2", a: [3, true, "Hello"] }.sorted_keys
    + # =>  ["a", "b", "c"]
    + { b: 1, c: "2", a: [3, true, "Hello"] }.sorted_keys
    + # =>  ["a", "b", "c"]
    + { b: 1, c: "2", b: [3, true, "Hello"] }.sorted_keys
    + # =>  ["b", "c"]
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_a + + + => + + + + + Array + + + +

    +

    +
    +
    +

    Returns two-dimensional array with the key-value pairs of hash. If specified true + then it will return sorted key value pairs array

    + +
     { a: 1, b: 2, c: 3 }.to_a
    + # => [["a", 1], ["c", 3], ["b", 2]] or [["b", 2], ["c", 3], ["a", 1]] ... etc
    + { a: 1, b: 2, c: 3 }.to_a(true)
    + # => [["a", 1], ["b", 2], ["c", 3]]
    + { b: 1, a: 2, c: 3 }.to_a(true)
    + # => [["a", 2], ["b", 1], ["c", 3]]
    + { b: 1, a: 2, a: 3 }.to_a(true)
    + # => [["a", 3], ["b", 1]]
    +
    + +
    +
    + + + +
      +
    • + Return: (Array) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_json + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns json that is corresponding to the hash. + Basically just like Hash#to_json in Rails but currently doesn’t support options.

    + +
     h = { a: 1, b: [1, "2", [4, 5, nil], { foo: "bar" }]}.to_json
    + puts(h) #=> {"a":1,"b":[1, "2", [4, 5, null], {"foo":"bar"}]}
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_s + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns json that is corresponding to the hash. + Basically just like Hash#to_json in Rails but currently doesn’t support options.

    + +
     h = { a: 1, b: [1, "2", [4, 5, nil], { foo: "bar" }]}.to_s
    + puts(h) #=> "{ a: 1, b: [1, \"2\", [4, 5, null], { foo: \"bar \" }] }"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + transform_values + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a new hash with the results of running the block once for every value. + This method does not change the keys and unlike Hash#map_values, it does not + change the receiver hash values.

    + +
     h = { a: 1, b: 2, c: 3 }
    + result = h.transform_values do |v|
    +   v * 3
    + end
    + h      # => { a: 1, b: 2, c: 3 }
    + result # => { a: 3, b: 6, c: 9 }
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + values + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns an array of values (in arbitrary order)

    + +
     { a: 1, b: "2", c: [3, true, "Hello"] }.keys
    + # =>  [1, "2", [3, true, "Hello"]] or ["2", [3, true, "Hello"], 1] ... etc
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/http.html b/docs/http.html new file mode 100755 index 0000000..ef16254 --- /dev/null +++ b/docs/http.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Http

    + +

    Description

    +
    +
    + +

    Class Methods

    +
    + +

    + # +

    + get + + + +

    +

    +
    +
    +

    Sends a GET request to the target and returns the HTTP response as a string.

    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + + + + + +

    Instance Methods

    +
    + +
    + +
    + + diff --git a/docs/index.html b/docs/index.html index 40e42d3..ec9fcaa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/integer.html b/docs/integer.html index 7585fe1..85b0d5d 100755 --- a/docs/integer.html +++ b/docs/integer.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -126,6 +156,1083 @@

    Class Methods

    Instance Methods


    +

    + # +

    + + + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the sum of self and another Integer

    + +
     1 + 2 # => 3
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + % + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Divides left hand operand by right hand operand and returns remainder.

    + +
     5 % 2 # => 1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + - + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the subtraction of another Integer from self.

    + +
     1 - 1 # => 0
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + * + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self multiplying another Integer

    + +
     2 * 10 # => 20
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + ** + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self squaring another Integer

    + +
     2 ** 8 # => 256
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + / + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self divided by another Integer

    + +
     6 / 3 # => 2
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + > + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is larger than another Integer

    + +
     10 > -1 # => true
    + 3 > 3 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + >= + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is larger than or equals to another Integer

    + +
     2 >= 1 # => true
    + 1 >= 1 # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + < + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is smaller than another Integer

    + +
     1 < 3 # => true
    + 1 < 1 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + <= + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is smaller than or equals to another Integer

    + +
     1 <= 3 # => true
    + 1 <= 1 # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + <=> + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns 1 if self is larger than the incoming Integer -1 if smaller. Otherwise 0.

    + +
     1 <=> 3 # => -1
    + 1 <=> 1 # => 0
    + 3 <=> 1 # => 1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + == + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is equal to another Integer

    + +
     1 == 3 # => false
    + 1 == 1 # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + != + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is not equal to another Integer

    + +
     1 != 3 # => true
    + 1 != 1 # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + ++ + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Adds 1 to self and returns.

    + +
     1++ # => 2
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + -- + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Substracts 1 from self and returns.

    + +
     0-- # => -1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + even + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is even.

    + +
     1.even # => false
    + 2.even # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_i + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self.

    + +
     100.to_i # => 100
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_s + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a String representation of self.

    + +
     100.to_s # => "100"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + next + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self + 1.

    + +
     100.next # => 101
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + odd + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns if self is odd.

    + +
     3.odd # => true
    + 4.odd # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + pred + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns self - 1.

    + +
     40.pred # => 39
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + times + + + +

    +

    +
    +
    +

    Yields a block a number of times equals to self.

    + +
     a = 0
    + 3.times do
    +    a++
    + end
    + a # => 3
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_int32 + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_int64 + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/method.html b/docs/method.html index afe1050..2cf7f1d 100755 --- a/docs/method.html +++ b/docs/method.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/null.html b/docs/null.html index 6650bb1..9ec3756 100755 --- a/docs/null.html +++ b/docs/null.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/object.html b/docs/object.html index 22f5aed..18c5b3a 100755 --- a/docs/object.html +++ b/docs/object.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/plugin.html b/docs/plugin.html new file mode 100755 index 0000000..6b0d7e0 --- /dev/null +++ b/docs/plugin.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Plugin

    + +

    Description

    +
    +

    PluginObject is a special type that contains a Go’s plugin

    +
    + +

    Class Methods

    +
    + + + + + +

    Instance Methods

    +
    + +

    + # +

    + send + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +
    + +
    + + diff --git a/docs/range.html b/docs/range.html index 74adb15..e9f4f52 100755 --- a/docs/range.html +++ b/docs/range.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + diff --git a/docs/string.html b/docs/string.html index 86d632c..b8fcf7c 100755 --- a/docs/string.html +++ b/docs/string.html @@ -42,6 +42,12 @@ + +
  • + Class +
  • +
    +
  • Error @@ -60,6 +66,12 @@
  • + +
  • + Http +
  • +
    +
  • Integer @@ -84,6 +96,12 @@
  • + +
  • + Plugin +
  • +
    +
  • Range @@ -96,6 +114,18 @@
  • + +
  • + Struct +
  • +
    + + +
  • + Uri +
  • +
    + @@ -136,6 +166,1775 @@

    Class Methods

    Instance Methods


    +

    + # +

    + + + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns the concatenation of self and another String

    + +
     "first" + "-second" # => "first-second"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + * + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns self multiplying another Integer

    + +
     "string " * 2 # => "string string string "
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + > + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a Boolean if first string greater than second string

    + +
     "a" < "b" # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + < + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a Boolean if first string less than second string

    + +
     "a" < "b" # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + == + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a Boolean of compared two strings

    + +
     "first" == "second" # => false
    + "two" == "two" # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + <=> + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns a Integer If first string is less than second string returns -1, if equal to returns 0, if greater returns 1

    + +
     "abc" <=> "abcd" # => -1
    + "abc" <=> "abc" # => 0
    + "abcd" <=> "abc" # => 1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + != + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns a Boolean of compared two strings

    + +
     "first" != "second" # => true
    + "two" != "two" # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + [] + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns the character of the string with specified index + It will raise error if the input is not an Integer type

    + +
     "Hello"[1]        # => "e"
    + "Hello"[5]        # => nil
    + "Hello\nWorld"[5] # => "\n"
    + "Hello"[-1]       # => "o"
    + "Hello"[-6]       # => nil
    + "Hello😊"[5]      # => "😊"
    + "Hello😊"[-1]     # => "😊"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + []= + + + => + + + + + String + + + +

    +

    +
    +
    +

    Replace character of the string with input string + It will raise error if the index is not Integer type or the index value is out of + range of the string length

    + +

    Currently only support assign string type value + TODO: Support to assign type which have to_s method

    + +
     "Ruby"[1] = "oo" # => "Rooby"
    + "Go"[2] = "by"   # => "Goby"
    + "Hello\nWorld"[5] = " " # => "Hello World"
    + "Ruby"[-3] = "oo" # => "Rooby"
    + "Hello😊"[5] = "🐟" # => "Hello🐟"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + capitalize + + + => + + + + + String + + + +

    +

    +
    +
    +

    Return a new String with the first character converted to uppercase but the rest of string converted to lowercase.

    + +
     "test".capitalize         # => "Test"
    + "tEST".capitalize         # => "Test"
    + "heLlo\nWoRLd".capitalize # => "Hello\nworld"
    + "😊HeLlO🐟".capitalize    # => "😊hello🐟"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + chop + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a string with the last character chopped

    + +
     "Hello".chop         # => "Hell"
    + "Hello World\n".chop # => "Hello World"
    + "Hello😊".chop       # => "Hello"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + concat + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a string which is concatenate with the input string or character

    + +
     "Hello ".concat("World")   # => "Hello World"
    + "Hello World".concat("😊") # => "Hello World😊"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + count + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the integer that count the string chars as UTF-8

    + +
     "abcde".count          # => 5
    + "ε“ˆε›‰οΌδΈ–η•ŒοΌ".count     # => 6
    + "Hello\nWorld".count   # => 11
    + "Hello\nWorld😊".count # => 12
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + delete + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a string which is being partially deleted with specified values

    + +
     "Hello hello HeLlo".delete("el")        # => "Hlo hlo HeLlo"
    + "Hello 😊 Hello 😊 Hello".delete("😊") # => "Hello  Hello  Hello"
    + # TODO: Handle delete intersection of multiple strings' input case
    + "Hello hello HeLlo".delete("el", "e") # => "Hllo hllo HLlo"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + downcase + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a new String with all characters is lowercase

    + +
     "erROR".downcase        # => "error"
    + "HeLlO\tWorLD".downcase # => "hello\tworld"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + empty + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if string is empty value

    + +
     "".empty      # => true
    + "Hello".empty # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + end_with + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if receiver string end with the argument string

    + +
     "Hello".end_with("llo")     # => true
    + "Hello".end_with("ell")     # => false
    + "😊Hello🐟".end_with("🐟") # => true
    + "😊Hello🐟".end_with("😊") # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + eql + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if receiver string is equal to argument string

    + +
     "Hello".eql("Hello")     # => true
    + "Hello".eql("World")     # => false
    + "Hello😊".eql("Hello😊") # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + gsub + + + => + + + + + String + + + +

    +

    +
    +
    +

    TODO: Implement String#gsub When RegexObject Implemented + Returns a copy of str with the all occurrences of pattern substituted for the second argument. + The pattern is typically a String or Regexp (Not implemented yet); if given as a String any + regular expression metacharacters it contains will be interpreted literally, e.g. ‘\d’ will + match a backslash followed by β€˜d’, instead of a digit.

    + +

    Currently only support string version of String#gsub.

    + +
     "Ruby Lang".gsub("Ru", "Go")                # => "Goby Lang"
    + "Hello 😊 Hello 😊 Hello".gsub("😊", "🐟") # => "Hello 🐟 Hello 🐟 Hello"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + include + + + => + + + + + Bool + + + +

    +

    +
    +
    +

    Checks if the specified string is included in the receiver

    + +
     "Hello\nWorld".include("\n")   # => true
    + "Hello 😊 Hello".include("😊") # => true
    +
    + +
    +
    + + + +
      +
    • + Return: (Bool) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + insert + + + => + + + + + String + + + +

    +

    +
    +
    +

    Insert a string input in specified index value of the receiver string

    + +

    It will raise error if index value is not an integer or index value is out + of receiver string’s range

    + +

    It will also raise error if the input string value is not type string

    + +
     "Hello".insert(0, "X") # => "XHello"
    + "Hello".insert(2, "X") # => "HeXllo"
    + "Hello".insert(5, "X") # => "HelloX"
    + "Hello".insert(-1, "X") # => "HelloX"
    + "Hello".insert(-3, "X") # => "HelXlo"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + length + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the character length of self + Note: the length is currently byte-based, instead of charcode-based.

    + +
     "zero".length # => 4
    + "".length     # => 0
    + "😊".length   # => 1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + ljust + + + => + + + + + String + + + +

    +

    +
    +
    +

    If input integer is greater than the length of receiver string, returns a new String of + length integer with receiver string left justified and padded with default “ “; otherwise, + returns receiver string.

    + +

    It will raise error if the input string length is not integer type

    + +
     "Hello".ljust(2)           # => "Hello"
    + "Hello".ljust(7)           # => "Hello  "
    + "Hello".ljust(10, "xo")    # => "Helloxoxox"
    + "Hello".ljust(10, "😊🐟") # => "Hello😊🐟😊🐟😊"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + replace + + + => + + + + + String + + + +

    +

    +
    +
    +

    Return a string replaced by the input string

    + +
     "Hello".replace("World")          # => "World"
    + "δ½ ε₯½"replace("再見")              # => "再見"
    + "Ruby\nLang".replace("Goby\nLang") # => "Goby Lang"
    + "Hello😊".replace("World🐟")      # => "World🐟"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + reverse + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a new String with reverse order of self + Note: the length is currently byte-based, instead of charcode-based.

    + +
     "reverse".reverse           # => "esrever"
    + "Hello\nWorld".reverse      # => "dlroW\nolleH"
    + "Hello 😊🐟 World".reverse # => "dlroW 🐟😊 olleH"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + rjust + + + => + + + + + String + + + +

    +

    +
    +
    +

    If input integer is greater than the length of receiver string, returns a new String of + length integer with receiver string right justified and padded with default “ “; otherwise, + returns receiver string.

    + +

    It will raise error if the input string length is not integer type

    + +
     "Hello".rjust(2)          # => "Hello"
    + "Hello".rjust(7)          # => "  Hello"
    + "Hello".rjust(10, "xo")   # => "xoxoxHello"
    + "Hello".rjust(10, "😊🐟") # => "😊🐟😊🐟😊Hello"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + size + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the character length of self + Note: the length is currently byte-based, instead of charcode-based.

    + +
     "zero".size  # => 4
    + "".size      # => 0
    + "😊".size   # => 1
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + slice + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a string sliced according to the input range

    + +
     "Hello World".slice(1..6)    # => "ello W"
    + "1234567890".slice(6..1)     # => ""
    + "1234567890".slice(11..1)    # => nil
    + "1234567890".slice(11..-1)   # => nil
    + "1234567890".slice(-10..1)   # => "12"
    + "1234567890".slice(-5..1)    # => ""
    + "1234567890".slice(-10..-1)  # => "1234567890"
    + "1234567890".slice(-10..-11) # => ""
    + "1234567890".slice(1..-1)    # => "234567890"
    + "1234567890".slice(1..-1234) # => ""
    + "1234567890".slice(-11..5)   # => nil
    + "1234567890".slice(-10..-5)  # => "123456"
    + "1234567890".slice(-5..-10)  # => ""
    + "1234567890".slice(-11..-12) # => nil
    + "1234567890".slice(-10..-12) # => ""
    + "Hello 😊🐟 World".slice(1..6)    # => "ello 😊"
    + "Hello 😊🐟 World".slice(-10..7)  # => "o 😊🐟"
    + "Hello 😊🐟 World".slice(1..-1)   # => "ello 😊🐟 World"
    + "Hello 😊🐟 World".slice(-12..-5) # => "llo 😊🐟 W"
    + "Hello World".slice(4)       # => "o"
    + "Hello\nWorld".slice(6)      # => "\n"
    + "Hello World".slice(-3)      # => "r"
    + "Hello World".slice(-11)     # => "H"
    + "Hello World".slice(-12)     # => nil
    + "Hello World".slice(11)      # => nil
    + "Hello World".slice(4)       # => "o"
    + "Hello 😊🐟 World".slice(6)      # => "😊"
    + "Hello 😊🐟 World".slice(-7)      # => "🐟"
    + "Hello 😊🐟 World".slice(-10)     # => "o"
    + "Hello 😊🐟 World".slice(-15)     # => nil
    + "Hello 😊🐟 World".slice(14)      # => nil
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + split + + + => + + + + + Array + + + +

    +

    +
    +
    +

    Returns an array of strings separated by the given separator

    + +
     "Hello World".split("o") # => ["Hell", " W", "rld"]
    + "Goby".split("")         # => ["G", "o", "b", "y"]
    + "Hello\nWorld\nGoby".split("o") # => ["Hello", "World", "Goby"]
    + "Hello🐟World🐟Goby".split("🐟") # => ["Hello", "World", "Goby"]
    +
    + +
    +
    + + + +
      +
    • + Return: (Array) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + start_with + + + => + + + + + Boolean + + + +

    +

    +
    +
    +

    Returns true if receiver string start with the argument string

    + +
     "Hello".start_with("Hel")     # => true
    + "Hello".start_with("hel")     # => false
    + "😊Hello🐟".start_with("😊") # => true
    + "😊Hello🐟".start_with("🐟") # => false
    +
    + +
    +
    + + + +
      +
    • + Return: (Boolean) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + strip + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a copy of str with leading and trailing whitespace removed. + Whitespace is defined as any of the following characters: null, horizontal tab, + line feed, vertical tab, form feed, carriage return, space.

    + +
     "  Goby Lang  ".strip   # => "Goby Lang"
    + "\nGoby Lang\r\t".strip # => "Goby Lang"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_a + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns an array of characters converted from a string

    + +
     "Goby".to_a       # => ["G", "o", "b", "y"]
    + "😊Hello🐟".to_a # => ["😊", "H", "e", "l", "l", "o", "🐟"]
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_i + + + => + + + + + Integer + + + +

    +

    +
    +
    +

    Returns the result of converting self to Integer

    + +
     "123".to_i # => 123
    + "3d print".to_i # => 3
    + "some text".to_i # => 0
    +
    + +
    +
    + + + +
      +
    • + Return: (Integer) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + to_s + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a new String with self value

    + +
     "string".to_s # => "string"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + +

    + # +

    + upcase + + + => + + + + + String + + + +

    +

    +
    +
    +

    Returns a new String with all characters is upcase

    + +
     "very big".upcase # => "VERY BIG"
    +
    + +
    +
    + + + +
      +
    • + Return: (String) : + + No Doc + +
    • +
    + + +
    +
    +

    + ( + source + ) +

    + diff --git a/docs/struct.html b/docs/struct.html new file mode 100755 index 0000000..1326456 --- /dev/null +++ b/docs/struct.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Struct

    + +

    Description

    +
    +

    StructObject …

    +
    + +

    Class Methods

    +
    + + + + + +

    Instance Methods

    +
    + +

    + # +

    + send + + + +

    +

    +
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + +
    + +
    + + diff --git a/docs/uri.html b/docs/uri.html new file mode 100755 index 0000000..20b6232 --- /dev/null +++ b/docs/uri.html @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + Goby API Documentation + + + +
    + + + + +
    +

    Uri

    + +

    Description

    +
    +
    + +

    Class Methods

    +
    + +

    + # +

    + parse + + + +

    +

    +
    +
    +

    Returns a Net::HTTP or Net::HTTPS’s instance (depends on the url scheme).

    + +
     u = URI.parse("https://example.com")
    + u.scheme # => "https"
    + u.host # => "example.com"
    + u.port # => 80
    + u.path # => "/"
    +
    + +
    +
    + + +
    +
    +

    + ( + source + ) +

    + + + + + +

    Instance Methods

    +
    + +
    + +
    + + diff --git a/parser.go b/parser.go index bbeb421..b04f8d0 100644 --- a/parser.go +++ b/parser.go @@ -50,8 +50,8 @@ func classFromFile(filepath string) Class { // ast.Print(fset, f.Comments) // Find class & methods - var classMethods *ast.ValueSpec - var instanceMethods *ast.ValueSpec + var classMethods *ast.FuncDecl + var instanceMethods *ast.FuncDecl // Loop through declarations for _, decl := range f.Decls { // Continue only for general declarations @@ -72,14 +72,14 @@ func classFromFile(filepath string) Class { decl := funcDecl.Name.Name // Assign instance methods if found if class.MatchInstanceMethods(decl) { - //instanceMethods = funcDecl - pp.Println("MatchInstanceMethods: ", decl) + instanceMethods = funcDecl + pp.Println("MatchInstanceMethods: ", funcDecl.Name.Name) } // Assign class methods if found if class.MatchClassMethods(decl) { - pp.Println("MatchClassMethods: ", decl) - //classMethods = funcDecl + classMethods = funcDecl + pp.Println("MatchClassMethods: ", funcDecl) } } } @@ -103,20 +103,24 @@ func classFromFile(filepath string) Class { return class } -func retrieveMethodsFromNode(fset *token.FileSet, valueSpec *ast.ValueSpec, allComments AllComments) []Method { +func retrieveMethodsFromNode(fset *token.FileSet, funcSpec *ast.FuncDecl, allComments AllComments) []Method { methods := []Method{} - allExpr := valueSpec.Values[0].(*ast.CompositeLit).Elts - var attrs []ast.Expr - for _, expr := range allExpr { - attrs = expr.(*ast.CompositeLit).Elts + + allStmt := funcSpec.Body.List[0] + stmt := allStmt.(*ast.ReturnStmt).Results[0] + exprs := stmt.(*ast.CompositeLit).Elts + for _, expr := range exprs { method := Method{} - // Attributes should only contain "Name" & "Fn" for now - for _, attr := range attrs { - thisExpr := attr.(*ast.KeyValueExpr) - name := thisExpr.Key.(*ast.Ident).Name + //kvs := exprs.Key.(*ast.Ident).Name + kvs := expr.(*ast.CompositeLit).Elts + for _, kv := range kvs { + k := kv.(*ast.KeyValueExpr).Key + v := kv.(*ast.KeyValueExpr).Value + name := k.(*ast.Ident).Name + // Attributes should only contain "Name" & "Fn" for now if name == "Name" { - method.FnName = strings.Replace(thisExpr.Value.(*ast.BasicLit).Value, "\"", "", -1) - method.FnLine = fset.Position(thisExpr.Key.(*ast.Ident).NamePos).Line + method.FnName = strings.Replace(v.(*ast.BasicLit).Value, "\"", "", -1) + method.FnLine = fset.Position(k.(*ast.Ident).NamePos).Line } if name == "Fn" { methodComments := allComments.findCommentFor(method.FnLine) @@ -124,6 +128,7 @@ func retrieveMethodsFromNode(fset *token.FileSet, valueSpec *ast.ValueSpec, allC method.Returns = methodComments.Returns method.Comment = template.HTML(methodComments.Description) } + pp.Println(method) } methods = append(methods, method) } diff --git a/settings.yml b/settings.yml index f3f32d0..58ec3cd 100644 --- a/settings.yml +++ b/settings.yml @@ -16,6 +16,6 @@ gobypath: "/src/github.com/goby-lang/goby" # # "https://github.com/goby-lang/goby/tree/f32c1fcbfd7e1df021948de1065d342e95ebd03d/vm/integer.go#L20" # -# The source always refers to a specific commit, so don't put in branch name like 'master' or 'development'. +# The source always refers to a specific commit, so don't put in branch kvs like 'master' or 'development'. repo: "https://github.com/goby-lang/goby" -commit: "a439b3a9fb4194c4ebe5388468d68cc755fa3b02" +commit: "25cfac50126b3cad0a28ba1334176b9d70a2ee04"