{"action":"created","issue":{"url":"https://api.github.com/repos/cn/GB2260.rb/issues/5","labels_url":"https://api.github.com/repos/cn/GB2260.rb/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/cn/GB2260.rb/issues/5/comments","events_url":"https://api.github.com/repos/cn/GB2260.rb/issues/5/events","html_url":"https://github.com/cn/GB2260.rb/issues/5","id":122185975,"number":5,"title":"to_s vs inspect","user":{"login":"fahchen","id":855678,"avatar_url":"https://avatars.githubusercontent.com/u/855678?v=3","gravatar_id":"","url":"https://api.github.com/users/fahchen","html_url":"https://github.com/fahchen","followers_url":"https://api.github.com/users/fahchen/followers","following_url":"https://api.github.com/users/fahchen/following{/other_user}","gists_url":"https://api.github.com/users/fahchen/gists{/gist_id}","starred_url":"https://api.github.com/users/fahchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fahchen/subscriptions","organizations_url":"https://api.github.com/users/fahchen/orgs","repos_url":"https://api.github.com/users/fahchen/repos","events_url":"https://api.github.com/users/fahchen/events{/privacy}","received_events_url":"https://api.github.com/users/fahchen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-15T03:33:45Z","updated_at":"2015-12-17T04:59:39Z","closed_at":null,"body":"https://github.com/cn/GB2260.rb/blob/master/lib%2FGB2260%2Fdivision.rb#L30-L32\r\n现在的 `to_s` 干的应该是 `inspect` 来干，为 `to_s` 添加可以传入分隔符作为参数的用途\r\n```ruby\r\ndef to_s(separator = '/')\r\n  [province, prefecture, county].compact.map(&:name).join(separator)\r\nend\r\n\r\ndef inspect\r\n  \"<GB2260-#{@revision} #{@code} #{[province, prefecture, county].compact.map(&:name).join('/')}>\"\r\nend\r\n```\r\n\r\n```ruby\r\ndc_dist = GB2260::Division.get(110101)\r\nputs dc_dist #=> 北京市/市辖区/东城区\r\nputs dc_dist.to_s #=> 北京市/市辖区/东城区\r\nputs dc_dist.to_s('-') #=> 北京市-市辖区-东城区\r\np dc_dist #=> <GB2260-2014 110101 北京市/市辖区/东城区>\r\n```"},"comment":{"url":"https://api.github.com/repos/cn/GB2260.rb/issues/comments/165337435","html_url":"https://github.com/cn/GB2260.rb/issues/5#issuecomment-165337435","issue_url":"https://api.github.com/repos/cn/GB2260.rb/issues/5","id":165337435,"user":{"login":"fahchen","id":855678,"avatar_url":"https://avatars.githubusercontent.com/u/855678?v=3","gravatar_id":"","url":"https://api.github.com/users/fahchen","html_url":"https://github.com/fahchen","followers_url":"https://api.github.com/users/fahchen/followers","following_url":"https://api.github.com/users/fahchen/following{/other_user}","gists_url":"https://api.github.com/users/fahchen/gists{/gist_id}","starred_url":"https://api.github.com/users/fahchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fahchen/subscriptions","organizations_url":"https://api.github.com/users/fahchen/orgs","repos_url":"https://api.github.com/users/fahchen/repos","events_url":"https://api.github.com/users/fahchen/events{/privacy}","received_events_url":"https://api.github.com/users/fahchen/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T04:59:39Z","updated_at":"2015-12-17T04:59:39Z","body":"根据 spec 加个 description 好像更合适\r\nhttps://github.com/cn/GB2260/blob/develop/spec.md#description"}}