Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions core/object.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,17 @@ class Object < BasicObject
# | (Exception, String message) -> bot
# | (singleton(Exception), String message) -> bot

# TODO: Symbol
# def self.attr_reader: (*String names) -> void
def self.attr_reader: (*Symbol names) -> void

# TODO: Symbol
# def self.attr_accessor: (*Symbol names) -> void
def self.attr_accessor: (*Symbol names) -> void

def include: (Module, *Module mods) -> void
def self.include: (Module, *Module mods) -> void

alias extend include
alias self.extend self.include

# TODO: Array, Symbol
# TODO: Array
# def self.constants: (?bool inherit) -> Array[Symbol]

def self.public: () -> void
Expand Down
7 changes: 3 additions & 4 deletions core/string.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ class String < Object

def strip!: () -> self?

# TODO: Symbol
# def to_sym: () -> Symbol
#
# alias intern to_sym
def to_sym: () -> Symbol

alias intern to_sym

def tr: (String pattern, String replace) -> String

Expand Down
14 changes: 14 additions & 0 deletions core/symbol.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Symbol < Object
# TODO: Array
# def self.all_symbols: () -> Array[Symbol]

def inspect: () -> String
def self.inspect: () -> String

def to_s: () -> String
def self.to_s: () -> String

alias id2name to_s

def to_sym: () -> Symbol
end
8 changes: 8 additions & 0 deletions test/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# rubocop:disable Lint/Void
# rubocop:disable Lint/UnreachableCode
# rubocop:disable Lint/UselessAccessModifier
# rubocop:disable Lint/DuplicateMethods
# rubocop:disable Style/CaseEquality
# rubocop:disable Style/ClassCheck
# rubocop:disable Style/FormatString
# rubocop:disable Style/RedundantFormat
# rubocop:disable Style/MixinGrouping
# rubocop:disable Style/AccessorGrouping
# rubocop:disable Layout/EmptyLinesAroundAccessModifier

# @type const TestMod: Module
Expand Down Expand Up @@ -82,6 +84,12 @@ module TestMod end

# @type const A: Class
class A
attr_reader :foo
attr_reader :foo, :bar, :baz

attr_accessor :foo
attr_accessor :foo, :bar, :baz

# @type const TestMod: Module
module TestMod end

Expand Down
5 changes: 5 additions & 0 deletions test/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# rubocop:disable Lint/Void
# rubocop:disable Lint/RedundantTypeConversion
# rubocop:disable Lint/SymbolConversion
# rubocop:disable Style/StringConcatenation

String.new
Expand Down Expand Up @@ -85,6 +86,10 @@

' abcdef '.strip!

'abcdef'.to_sym

'abcdef'.intern

'abcdef'.tr 'a-z', 'n-za-m'

'abcdef'.tr! 'a-z', 'n-za-m'
Expand Down
16 changes: 16 additions & 0 deletions test/symbol.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# rubocop:disable Lint/SymbolConversion
# rubocop:disable Lint/RedundantTypeConversion

:foo.inspect
Symbol.inspect

:foo.to_s
Symbol.to_s

:foo.id2name

:foo.to_sym

# rubocop:enable all